在PHP 5.4.0,標籤<?=..
始終可用無論short_open_tag
INI設置。 Source
的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 ?>
到<?= ?>
你需要在'php.ini'中改變。 _short_open_tag默認值:On_ –
@FrayneKonok我假設OP使用PHP 5.4+。如果是這種情況,無論php.ini中的值如何,始終都可以使用<?= =。 – Mike
尋找'short_open_tag = Off'如果沒有,就把它打開。 –