compatibility of <?= shortcut
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!
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 document when talking about short_open_tag
directive says:
This directive also affects the shorthand <?=
, which is identical to <? echo
<? echo
. Use of this shortcut requires short_open_tag
to be on
.
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.
链接地址: http://www.djcxy.com/p/59444.html上一篇: 什么是反对使用“<?=”的论据?
下一篇: <?=快捷方式的兼容性