Getting Started with PHP
To embed PHP into HTML you must '<?php' to start the script and '?>' to to end it. PHP can be placed into any part of a web page, event before the opening '<html>' tag, however, this is generally for processing information rather than displaying it.
The example below embeds some PHP into a paragraph to display the contents of a variable, which has been previously defined.
<?php $hello = "Hello world"; ?> <!DOCTYPE html> <html> <body> <p><?php echo $hello; ?></p> </body> </html>
As with any programming or scripting language, it is good practice to include comments to make it easier to understand your code. You can either use single or multi-line comments as shown below.
<?php // This is a single line comment. /* This is a multi line comment */ ?>