从php5.4中,可以使用<?= ...?>替换<?php echo ...;?>。
因此,我想在我的项目中替换.php文件中的所有这些文件。我该怎么换呢?
或者它不能自动转换吗?
我找到了用[] (thomasbachem/php短数组语法转换器)代替[]的脚本。有人知道这种事吗?
(这可能在任何地方都存在,但是google很难通过有许多符号的查询进行搜索.)
发布于 2016-05-29 03:51:57
如果在short_open_tags中启用了php.ini,则可以使用<?= ...?>代替默认的打开标记。
将所有程序语句转换为
<?php
echo $var;
?>至
<?=$var ?>必须手工完成。虽然我在github上发现了一些相反的脚本(将短标记转换为长标记),但我不知道有哪个转换器脚本可以实现它的自动化。
发布于 2016-05-29 03:51:53
在PHP5.4.0中,标记<?=..总是可用的,而不管short_open_tag ini设置如何。来源
php.ini
; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php and ?> tag combination. With the wide spread use
; of XML and use of these tags by other languages, the server can become easily
; confused and end up parsing the wrong code in the wrong context. But because
; this short cut has been a feature for such a long time, it's currently still
; supported for backwards compatibility, but we recommend you don't use them.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag=Off之后,您可以将
<?php echo ?>更改为<?= ?>。
发布于 2016-05-30 20:54:49
在您的php.ini中更改标记:
short_open_tag=Off到:
short_open_tag=On.那就解决了你的问题
https://stackoverflow.com/questions/37505937
复制相似问题