Embed PHP into HTML

PHP code can be embedded into any HTML web page by using the <?php  ?> tags.

<html>
    <head>
        <title>My PHP Page</title>
    </head>
    <body>
        <?php
            echo "Hello World!";
        ?>
    </body>
</html>

Most web servers will only interpret php code in pages with a .php file extension.

If for some reason you cannot change the file extention to .php you can configure your web server to interpret PHP tags in .htm or .html pages by adding the following line to either your .htaccess file or your apache httpd.conf file.

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