我在Linux服务器上有一个web应用程序,以<?
我需要将这个应用程序复制到windows环境中,一切工作正常,除了SQL语句呈现不同。我不知道这是否与以<?用PHP代替<?因为我不知道从哪里启用<?所以我把它改为<?php
我知道这两个语句应该是相同的,但我需要用<?以确保应用完全相同。这样我就可以排除另一种可能性。
谢谢
我在Linux服务器上有一个web应用程序,以<?
我需要将这个应用程序复制到windows环境中,一切工作正常,除了SQL语句呈现不同。我不知道这是否与以<?用PHP代替<?因为我不知道从哪里启用<?所以我把它改为<?php
我知道这两个语句应该是相同的,但我需要用<?以确保应用完全相同。这样我就可以排除另一种可能性。
谢谢
当前回答
在CentOS 6中(在CentOS 7上也进行了测试),您不能在/etc/php.ini中为php-fpm设置short_open_tag。 你会有错误:
ERROR: [/etc/php.ini:159] unknown entry 'short_open_tag'
ERROR: Unable to include /etc/php.ini from /etc/php-fpm.conf at line 159
ERROR: failed to load configuration file '/etc/php-fpm.conf'
ERROR: FPM initialization failed
您必须编辑站点的配置,该配置可以在/etc/php-fpm.d/www.conf中找到 并在文件末尾写道:
php_value[short_open_tag] = On
其他回答
在\apache\Apache2.2.21\bin\php.ini和\bin\php\php5.3.8\php.ini文件中设置asp_tags = On和short_open_tag = On,然后重新启动apache服务器。
对于Wamp服务器用户有一个更简单的方法: 您可以启用该设置,只需(左)点击WampServer图标,选择PHP -> PHP设置->短打开标签。等待一秒钟,WampServer将自动重新启动PHP和它的web服务。
原文:http://osticket.com/forums/showthread.php?t=3149
在Ubuntu上设置从Vagrant安装脚本打开短标签:
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php5/apache2/php.ini
这可以通过在php.ini中启用short_open_tag来实现:
short_open_tag = on
如果你没有访问php.ini,你可以尝试通过。htaccess文件启用它们,但如果你是在共享主机上,主机公司可能会禁用它:
php_value short_open_tag 1
对于那些认为short_open_tags在php5.4中是不好的做法的人来说,<?=……> shorttag在任何地方都将被支持,不管设置如何,所以如果你可以控制服务器上的设置,没有理由不使用它们。在这个链接中还提到:short_open_tag
我已经在我的aws centos 7实例和php7(PHP 7.0.33 (cli)(构建:2018年12月6日22:30:44)(NTS)上更改了short_open_tag Off到On,但它没有反映PHP信息页面和代码。所以我参考了医生的文件,找到了解决我的问题的办法。在short_open_tag后面添加额外的一行,作为asp_tags = On,重启Apache后,它可以在代码上工作,我正确地输出
php . ini文件
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 is ; generally recommended that <?php and ?> should be used and that this feature ; should be disabled, as enabling it may result in issues when generating XML ; documents, however this remains supported for backward compatibility reasons. ; Note that this directive does not control the <?= shorthand tag, which can be ; used regardless of this directive. ; Default Value: On ; Development Value: Off ; Production Value: Off ; http://php.net/short-open-tag short_open_tag = On ; Allow ASP-style <% %> tags ; http://php.net/asp-tags asp_tags = On