doudi7782 2009-10-20 06:50
浏览 23
已采纳

<?php vs <? …有关系吗? [重复]

Possible Duplicate:
Are PHP short tags acceptable to use?

<?php
    //Some code
?>

or

<?
    //Some code
?>

I know the first way is the proper way but PHP code isn't validated. So, besides it saving extra typing & bytes, does it matter?

update Thanks for the replies...

  1. I had no idea they were called short tags (hence why I didn't find the duplicate SO question)
  2. I had no idea there was a specific server configuration option to allow/disallow the short tags.

Thanks again

  • 写回答

6条回答 默认 最新

  • duanfei1987 2009-10-20 06:52
    关注

    It does, if anyone ever uses your code on a server where short tags are disabled. I work with several servers where they are. Other than that though, no. Using the short version makes your script less portable though for the above mentioned reason. This may or may not be an issue for you.

    This is another issue entirely, but related. If you are trying to generate certain types of files from PHP (XML is the candidate that comes up most often for me) then having short tags can be an issue. For instance, the following causes a PHP syntax error:

    <?xml version="1.0" ?>
    

    You must instead write the following on a server that has short tags enabled:

    <?php echo '<?xml version "1.0" ?>'; ?>
    

    Gah!

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

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图