PHP - Syntax and Tags

The PHP syntax is a set of rules that define how a program should be written. PHP is, in that sense, no different from any other language. If I wrote this sentence backward and upside down, it would not be following the rules, and it is doubtful that anyone would understand it. The PHP interpreter expects certain rules to be followed, and will spit errors at you if they are not followed.

All code written in PHP must be identified as PHP code. A set of tags are used to mark the beginning and end of a block of code, in between which any amount of code can be written.

The standard opening tag is:

The standard closing tag is:

?>

These tags can be used to jump in and out of "PHP mode" any number of times in a PHP file, including a PHP file containing HTML elements.

 

 

 

 

 

 

 

 

One other set of tags is readily available, but not practical when there is the shorter alternative. This set is:

 

Also, several sets of tags are available if PHP's configuration is set to allow their usage, which make them less portable and not desirable for general use:

<?   ?>

<?   ?>

<%   %>

<%=   %>