I w...">

How to run PHP in HTML?

If I have 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 to put a .php file in index.html?

+4
source share
2 answers

Rename index.html to index.php and fill it as follows:

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

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 
+2
source

All Articles