我在Linux服务器上有一个web应用程序,以<?

我需要将这个应用程序复制到windows环境中,一切工作正常,除了SQL语句呈现不同。我不知道这是否与以<?用PHP代替<?因为我不知道从哪里启用<?所以我把它改为<?php

我知道这两个语句应该是相同的,但我需要用<?以确保应用完全相同。这样我就可以排除另一种可能性。

谢谢


当前回答

 short_open_tag = On

在php . ini中 并重新启动Apache服务器。

其他回答

您需要打开short_open_tags。

short_open_tag = On

如果您编辑了php.ini文件,请记得重新启动服务(apache2等),以便对php.ini的编辑生效

我看到上面所有的答案都是部分正确的。 实际上,所有21世纪的PHP应用程序都有FastCGI进程管理器(PHP -fpm),所以一旦你在test.php脚本中添加了PHP -info(),并检查了PHP .ini的正确路径

Go to php.ini and set short_open_tag = On

重要提示:然后你必须重新启动你的php-fpm进程,这样才能工作!

sudo service php-fpm restart

最后重新启动nginx/http服务器

sudo service nginx restart

我已经在我的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

 short_open_tag = On

在php . ini中 并重新启动Apache服务器。