DarkLightA
DarkLightA

Reputation: 15692

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?

Upvotes: 4

Views: 17880

Answers (2)

Cris Ravazzano
Cris Ravazzano

Reputation: 57

This worked for me:

Add the following to your .htaccess file

AddType application/x-httpd-php .php .htm .html
AddHandler application/x-httpd-php5 .html .php .htm

Upvotes: 2

phihag
phihag

Reputation: 288260

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

<html>
<head></head>
<?php
require('./file.php');
?>
</html>

Upvotes: 11

Related Questions