dslh32311 2011-06-22 19:51
浏览 81
已采纳

<?php?>和<?的php语法不同? ?> [重复]

Possible Duplicates:
What is the difference between the PHP open tags “<?=” and “<?php”/“<?”?
Reference - What does this symbol mean in PHP?

Is there really any difference in writing the syntax like <?php ?> or as <? ?>.

I was under the impression that it really didn't matter as long as the file had an .php extension. But sometimes I seem to run into problems with the syntax.

so whats the lowdown?

  • 写回答

3条回答 默认 最新

  • dstxpei5823 2011-06-22 19:52
    关注

    The latter is called shorttags.

    You can disable those tags in php's configuration, apart from that there is not really a difference.

    Because you can disable them, you should not use them, as they can cause lots of unexpected problems when you happen to run your scripts on servers where you can't enable them. Another reason, as noted by Sjoerd in the comment is, that they can cause conflicts when you have an XML header for instance.

    If you enable short tags though, you get a shorthand syntax for the echo function: <?= $string ?>

    It's enabled using the short_open_tag setting in php.ini. You can read about it here.

    Update As of PHP 5.4.0 alpha1:

    <?= is now always available regardless of the short_tags setting (Rasmus)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效