PHP 04: PHP Tags
PHP codes must be enclosed by PHP tags. When PHP parser pareses a file , it looks for opening and closing PHP tags. It tells the parser when to start interpreting and when to stop. Reason for parsing in this manner is allowing to embed in different types of documents like HTML.
Example of PHP standard tag
Look at the code below
|
It is recommended to use PHP standard tag for compatibility an this tag can not be disabled by php.ini
settings.
Example of PHP short tag
|
To use PHP short tag short_open_tag
must be set to On
in php.ini
settings. But use of of PHP short open tag is not recommended.
If the file contains only PHP code, you can omit the end tag to avoid error due to whitespace added after the end tag. See the code below.
|
Note
The ASP tags <%
, %>
, <%=
and the script tag <script language="php">
are removed from PHP 7.