开发者

Which PHP tags are always available?

Of the 4 types of PHP tags:

  • Standard tag : <?php ...?>
  • Short tag : <? .... ?>
  • Script tag: <script langua开发者_StackOverflow社区ge=“php”> ... </script>
  • ASP tag : <% ... %>

Which is/are always available ?


The standard <?php and the <script> tags are always available.

The two others depend on configuration settings.

From the reference:

There are four different pairs of opening and closing tags which can be used in PHP. Two of those, <?php ?> and <script language="php"> </script>, are always available. The other two are short tags and ASP style tags, and can be turned on and off from the php.ini configuration file. As such, while some people find short tags and ASP style tags convenient, they are less portable, and generally not recommended.

Short tags are only available when they are enabled via the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option.

ASP style tags are only available when they are enabled via the asp_tags php.ini configuration file directive.


You should always use the PHP tags <?php and ?>.

These tags will always be available on a PHP server, whereas the shorthand tags (<? + ?>) can be turned on and off in the php.ini file, I generally go with <?php ?> as this increases portability.


so far I know PHP's short opening tag is going to be completed deprecated from PHP 6. So it is beast to use .


You have to use <?php tag. You can use <? tag when the "short open tag" property is "On" in your php.ini file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜