PHP is an embedded scripting language; this means that it is possible to write PHP code into an HTML file. Since web browsers can only process HTML files, the web-server converts and embeds the PHP code into one HTML file before sending it to the browser.
There are HTML tags for PHP code to indicate the start and end of PHP code in an HTML file. Any one of the following 4 tags can be used:
<?php
php-code-here ?>
<SCRIPT LANGUAGE="php">
php-code-here </SCRIPT>
<?
php-code-here ?>
<%
php-code-here %>
The first and second tags are the ones most recommended and most widely used. Using a tag which is rarely used may result in a web-server being unable to detect the start and end of the PHP code.
#
and //
are used to comment out a single line of code, while /*
and */
indicate the start and end of a commented block of code.
<?phpprint "Hello";echo " World!\n";/* Commenting out a block of codeecho 'This line won't execute.\n';*/# The last line does not require a semicolonprint "The last line."?>