PHP 5.3 magic_quotes_gpc但没有工作

时间:2014-03-25 16:52:41

标签: php fastcgi magic-quotes-gpc

我对magic_quotes_gpc有疑问。我正在将网络服务器从XP机器迁移到Win2003机器。 PHP代码在某些情况下是陈旧的,并没有很好地开发,所以我真的需要让magic_quotes_gpc工作。

我很确定配置正确,我还尝试复制旧的PHP文件夹和php.ini,但仍然有问题。 magic_quotes_gpc = On具有magic_quotes_gpc = Off的确切行为。

尝试使用PHP 5.3,但即使旧的5.1在旧服务器上正常工作。

唯一的区别是在新服务器中我使用的是FastCGI。

我真的在你手中解决这个问题,我真的变得疯狂了!

20140326 - 根据Alvaro建议添加代码示例

<?
  print $_GET["id"];
  print '<br><br>';
  print $_GET[id];
?>

调用页面./sample.php?id=1,仅显示此行(我发现错误):

PHP Notice: Use of undefined constant id - assumed 'id' in C:\Inetpub\wwwroot\simple.php on line 4

评论第4行:

<?
  print $_GET["id"];
  print '<br><br>';
  //print $_GET[id];
?>

预期输出为1.

1 个答案:

答案 0 :(得分:1)

您的测试代码与magic quotes完全无关,因此我怀疑您误解了该功能的作用。使用魔术引号,您可以调用此网址:

/test.php?foo=O'Hara

...其中test.php是:

<?php
var_dump($_GET);

......然后回复:

array(1) {
  ["foo"]=>
  string(7) "O\'Hara"
}

......而不是:

array(1) {
  ["foo"]=>
  string(6) "O'Hara"
}

但是,您尝试使用不存在的常量,如下所示:

<?php
define('this_exists', 'yes');
echo this_exists;
echo this_does_not_exist;

...你可能希望PHP不会警告你错误:

  

PHP注意:使用未定义的常量this_does_not_exist - 假设&#39; this_does_not_exist&#39;

所以你基本上想要摆弄error_reporting并省略E_NOTICE