我有一个使用
<?=$variable?>
语法而不是
<?php echo $variable; ?>
我想让它在我的本地主机上工作。我需要在我的 php.ini 文件中启用什么来执行此操作?
请注意,我不是在问如何启用 short_open_tag,而是在问如何在 CodeIgniter 中启用它。
提前致谢..
我有一个使用
<?=$variable?>
语法而不是
<?php echo $variable; ?>
我想让它在我的本地主机上工作。我需要在我的 php.ini 文件中启用什么来执行此操作?
请注意,我不是在问如何启用 short_open_tag,而是在问如何在 CodeIgniter 中启用它。
提前致谢..
在 CodeIgniter 中config.php
:
/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files. Options are TRUE or FALSE (boolean)
|
*/
$config['rewrite_short_tags'] = FALSE;
这也意味着它不依赖于主机。
最好在服务器上启用短格式标签。这将阻止 CodeIgniter 重写您的标签。
在 PHP 安装目录中找到 PHP.ini 文件。搜索“short_open_tag”。您将在“语言选项”下看到它被多次引用。找到未注释的并将其更改为打开。
INI 看起来像这样:
;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;;;;;;;;;;;;;;;;;;;;
; Enable the PHP scripting language engine under Apache.
; http://php.net/engine
engine = On
; 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
; XAMPP for Linux is currently old fashioned
short_open_tag = On