PHP delimiters are nothing but the open close tags to enclose PHP script. PHP code can be parsed if and only if it is enclosed with these delimiters.
There are various set of delimiters to recognize PHP code. These are as listed below.
Let us look into the php.ini directive settings that affects the PHP delimiters to be used.
This directive is used to specify whether the short form for PHP delimiters, that is, <?…?> , is allowed or not. This PHP language option will be set with ON/OFF values and the default value is ON. When it is set as ON, then it is allowed to use the short form (<?…?>) to write PHP code which will be recognized by PHP parser. If it is set as OFF, then the PHP code can not be parsed .
This method of writing PHP program by enclosing it with <? and ?> is not recommended programming practice. Because, if we launch our code that contains <? and ?> open, close tags, into other PHP server, where short_open_tag directive is not enabled, then the code will not work at that server.
Though PHP short tags are not portable among different servers, still they are allowed for providing backward compatibility.
This form is used to print something to the browser. For example, a PHP echo statement can be written as follows.
$statement = "PHP Open and Close Tags"; <?=$statement;?>
From the above list of ways to represent PHP tags, the forth possible form, that is, <?=;>was also included with this constraint depends on the value of short_open_tag directive as of earlier PHP versions. But, as of PHP version 5.4, this form will also be portable like first two delimiters, for launching our code having this notation, into another server.
This option is used to allow to recognize PHP code enclosed with the open close tags used in Active Server Pages (ASP) scripting, that is like, <%…%>.
We can search for this tag in php.ini file. If it is enabled by having the value ON, then the PHP scripts inside the open close tags, <%,%> will be executed, and also, the alternative ASP print statement representation, like, <%=;%> also allowed. Otherwise, the script including asp tags will be displayed to the browser.
As like PHP short tags <? and ?>, asp style tags also depends on PHP configuration settings. So, this form of tags are also not preferable to develop PHP projects to be launched in other server, because of the the lack of portability.
This PHP code tutorial was published on June 26, 2013.