There are four different pairs of
opening and closing tags which can be
used in PHP. Two of those, <?php ?>
and ,
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.
根据我的经验,大多数服务器都启用了短标签.打字
=
打字要方便得多
程序员的便利是一个重要因素,为什么不推荐他们?
解决方法:
如果您不得不将代码移动到不受支持的服务器(并且您无法启用它),则不建议使用它们,因为它是PITA.正如你所说,许多共享主机确实支持短标签,但“批次”不是全部.如果要共享脚本,最好使用完整语法.
我同意
我根本不把可读性作为理由.最认真的开发人员可以选择语法突出显示.
正如ThiefMaster在评论中提到的,as of PHP 5.4, = ... ?> tags are supported everywhere, regardless of shorttags settings.这应该意味着它们在可移植代码中使用是安全的,但这确实意味着它依赖于PHP 5.4.如果你想支持5.4之前并且不能保证短标签,你仍然需要使用.
标签:php-shorttags,php,coding-style
来源: https://codeday.me/bug/20190910/1802195.html