开发者

What's the difference between <?php ?> and <? ?>

I can't find the answer 开发者_如何学JAVAanywhere. Thanks!


Basically,

<? ?> are short tags. However, not every php installation has short tags enabled. Therefore, even though is faster to type than the normal tags (<?php ?>), it may not work if you move your code to another server.

Are PHP short tags acceptable to use?

EDIT: Also, if you're using xml in your web page, you might run into conflicts, as writing <?xml version="1.0"?> will make you run into a PHP error, as xml version="1.0" isn't PHP!

If you're using XML and PHP you may need to <?php echo "<?xml version=\"1.0\""; ?>


In your php.ini, if you want <? and ?> to work, you need to turn on "short tags". However, it is better to write long-tag compliant code in the first place.

Acutally is no difference.


They both mean the same, with the difference that the short form <? ?> is not always supported/enabled.


There acutally is no difference between the two, the second one is bascially just a shorthand. I personally would recommend using the longer version, because on some systems, the second possibilty is disabled in the php.ini (see short_open_tags).


It is always better to use <?php ?> as on some installations of php <? ?> is not supported! If this happens your code will not work!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜