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

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

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

谢谢


当前回答

我看到上面所有的答案都是部分正确的。 实际上,所有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

其他回答

要使用php-fpm为特定的域启用short_open_tag,您必须编辑:

/etc/php5/fpm/pool.d/xxxxx.conf

其中xxxxx为域的套接字号。

add: php_value[short_open_tag] = On

您需要打开short_open_tags。

short_open_tag = On
 short_open_tag = On

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

如果你在windows中使用xampp,请按以下步骤操作

打开XAMPP控制面板。 点击CONFIG按钮。 进入PHP (PHP .ini)选项。

使用ctrl+f实用程序找到short_open_tag

您将找到;short_open_tag

请从行中删除分号(;)。

并将其保留为short_open_tag = on

最后,重新启动Apache服务器

对于docker,将此步骤添加到Dockerfile中

  ARG phpIniPath=/path/to/your/php.ini

  RUN sed -i -e 's/^short_open_tag\s*=.*/short_open_tag = On/' $phpIniPath