Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run PHP in HTML?

If I have a file, file.php, in the same directory as index.html:

file.php:

<?php
echo "<body><img src=\"hi.jpg\" /><br /><p>I was here</p>"
?>

index.html:

<html>
<head></head>
<!-- I want to enter the PHP in file.php here --></body>
</html>

How do I put file.php in index.html?

like image 588
DarkLightA Avatar asked Dec 16 '22 13:12

DarkLightA


1 Answers

Rename index.html to index.php, and fill it with the following:

<html>
<head></head>
<?php
require('./file.php');
?>
</html>
like image 105
phihag Avatar answered Jan 02 '23 08:01

phihag