PHP短开始标签问题

  PHP5.1发布后php.ini的设置有一个重要的地方发生了变化,那就是short_open_tag,在windows下的PHP5.1附带的文件中php.ini-dist的short_open_tag = on,而php.ini-recommended的short_open_tag = off,这样就很有可能有部分PHP服务器将会不支持short_open_tag,也就是<?标签。

  我将php.ini中关于这个设置的说明对照翻译如下:

  • Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
    NOTE: Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server. For portable, redistributable code, be sure not to use short tags.
  • 允许<?标签。否则只可以使用<?php和<script>标签。
    注意:意图发布或者运用在不是你控制下的PHP服务器上的应用程序或者源码库,其开发时应该避免使用短标签,这是因为短标签可能在目标服务器上无法被支持。为了代码的便捷和可发布性,请确定没有使用短标签。

  为了程序的规范性和可靠性,最好不要再使用<?,全部改用<?php,想来目前国内的大部分程序,还都在使用<?或者<?=这样的简写形式,在Dz、PW、Molyx中都能找到<?,希望国内程序开发者能及时调整编码规范。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据