如何在 PHP 中设置短标签(<?)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4645898/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set short tag(<?) in PHP?
提问by Ashvin
I am using WAMPP for PHP server and in programming short tag use create a problem. I knew that it possible by change something in php.ini file but I don't know the setting for that please help me for that.
我正在将 WAMPP 用于 PHP 服务器,并且在编程中使用短标签会产生问题。我知道可以通过更改 php.ini 文件中的某些内容,但我不知道该设置,请帮助我。
example:
例子:
<? echo "hi"; ?> //error....want to allow this also.
<?php echo "hi"; ?> //ok
I found this in PHP config setting file but what changes require I don't know...
我在 PHP 配置设置文件中找到了这个,但我不知道需要哪些更改...
; short_open_tag
; Default Value: On
; Development Value: Off
; Production Value: Off
回答by Diablo
In your php.ini change the short_open_tag = Off
if it's there to this:
在您的 php.ini 中,short_open_tag = Off
如果它在那里,请更改为:
short_open_tag = On
回答by Hafiz
Click on your wamp icon then "PHP". Then click on "PHP Settings". There should be an option for "short open tag" which you should enable by clicking on it, it should show a check mark. Your wamp server will automatically restart in a few seconds and then short open tag will be enabled.
单击您的 wamp 图标,然后单击“PHP”。然后点击“PHP设置”。应该有一个“short open tag”选项,您应该点击它来启用它,它应该显示一个复选标记。您的 wamp 服务器将在几秒钟内自动重新启动,然后将启用短开标签。
For non-wamp you need to go to your php.ini file and uncomment short_open_tag = On
对于非 wamp,您需要转到 php.ini 文件并取消注释 short_open_tag = On
回答by Nik
set short_open_tag = 1
in your php.ini file.
short_open_tag = 1
在你的 php.ini 文件中设置。
回答by IqbalBary
Sometime setting short_open_tag = On
on your php.ini will not work because in some cases, short_open_tag
define more than one. So find all short_open_tag
and set On
or 1
.
有时short_open_tag = On
在 php.ini 上的设置不起作用,因为在某些情况下,short_open_tag
定义不止一个。所以找到 allshort_open_tag
并设置On
or 1
。
short_open_tag = On
回答by Carter Cole
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /etc/php.ini
grep -n short_open_tag php.ini
first line does inlien replace of php.ini to turn on short tags second makes sure its there
第一行确实替换了 php.ini 以打开短标签,第二行确保它在那里
回答by Quirijn
Wamp 2.5 contains two versions of php.ini. If you're running php inside Apache (as I guess you are) you need to change the one in \bin\apache\apache2.4.9\bin.
Wamp 2.5 包含两个版本的 php.ini。如果你在 Apache 中运行 php(我猜你是),你需要更改 \bin\apache\apache2.4.9\bin 中的那个。