PHP Syntax

PHP Syntax You cannot view the PHP source code by selecting “View source” in the browser – you will only see the output from the PHP file, which is plain HTML. This is because the scripts are executed on the server before the result is sent back to the browser.
 
Now that you are aware of how PHP scripts are executed, let’s discuss how to actually write your first PHP script. All PHP scripts are written in what are called code blocks. These blocks can be embedded into HTML, if desired, and are generally defined by <?php at the start and ?> at the end.
 
NOTE PHP Syntax
 
Although <?php and ?> are generally used,
the following are also valid code-block separators:
<? … ?> Shorthand version of <?php and ?>

<% … %> NOTE Although <?php and ?> are generally used, the following are also valid code-block separators:

<? … ?> Shorthand version of <?php and ?>

<% … %> ASP style
<SCRIPT LANGUAGE=”PHP”>

</SCRIPT>
HTML editor compatible syntax

 
Note that some of these code block separators function only when the associated php.ini configuration directive is enabled. Unless there is a specific reason not to, using the default <?php and ?> tags is strongly recommended.ASP style
 
<SCRIPT LANGUAGE="PHP">
 
...
   
</SCRIPT>
 
HTML editor compatible syntax
 
Note that some of these code block separators function only when the associated php.ini configuration directive is enabled. Unless there is a specific reason not to, using the default <?php and ?> tags is strongly recommended.