开发者

PHP - compatibility of <?= shortcut [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicates:

Are PHP short tags acceptable to use?

Reference - What does this symbol mean in PHP?

Hi Guys,

I can't seem to find any information about the <?= shortcut of php. Does 开发者_开发知识库anyone of you know more about that?

Thanks in advance!


The document when talking about short_open_tag directive says:

This directive also affects the shorthand <?=, which is identical to <? echo. Use of this shortcut requires short_open_tag to be on.


You are looking for the PHP ini directive short_open_tag It enables the support for <? instead of <?php

From the docs:

Note:

This directive also affects the shorthand <?=, which is identical to

short_open_tag to be on.

There has been no announcement whatsoever that support should be discontinued. You can regard <?= as supported as <?=.

There are however some weird preconfigured systems that don't have it enabled by default.

For example some debian version in early php5 versions.

So to be on the save side you should do <?php

php.net also says:

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.

which i would interpret at, you are totally fine as long as you can control your settings.

Documentation is here: http://php.net/manual/en/ini.core.php and here: http://www.php.net/manual/en/language.basic-syntax.phpmode.php


The manual entry on these short tags has this to say about compatibility

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜