为什么有的机器支持<? ?>有的不支持,必须要写成<?php ?>谁知道这是为什么?跟什么有关呢!因为现在程序里很多都是这样用的,修改起来量太大了!

解决方案 »

  1.   

    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.
    short_open_tag = On; Allow ASP-style <% %> tags.
    asp_tags = Off
      

  2.   

    PHP 的脚本块以 <?php 开始,以 ?> 结束。您可以把 PHP 的脚本块放置在文档中的任何位置。当然,在支持简写的服务器上,您可以使用 <? 和 ?> 来开始和结束脚本块。不过,为了达到最好的兼容性,我们推荐您使用标准形式 (<?php),而不是简写形式。