0

我有一个使用

<?=$variable?>

语法而不是

<?php echo $variable; ?>

我想让它在我的本地主机上工作。我需要在我的 php.ini 文件中启用什么来执行此操作?

请注意,我不是在问如何启用 short_open_tag,而是在问如何在 CodeIgniter 中启用它。

提前致谢..

4

4 回答 4

5

在 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;

这也意味着它不依赖于主机。

于 2012-07-18T01:05:54.923 回答
3

阅读此内容:PHP Short Open Tag:方便快捷或更改安全性?

于 2012-07-18T01:02:56.070 回答
3
  1. 在您的 php 安装目录中搜索 php.ini 文件
  2. 用任何文本编辑器打开它,然后再次搜索“short_open_tag”,如果你找到像“;short_open_tag = Off”这样的行,然后删除“;” 并重新启动您的 apache 服务器它将工作。但我强烈要求您不要使用 php 短标签,因为并非所有 Web 服务器都接受 php 短标签。
于 2012-10-19T07:05:45.550 回答
0

最好在服务器上启用短格式标签。这将阻止 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
于 2012-07-18T01:20:36.723 回答