在下面的代码中,我们可以看到 5 个使用未定义变量的示例。启用错误报告和显示后,我们应该会看到 5 个通知。然而,在 php 5.5 中,当使用“http 解释器”时,我们只会看到其中的 3 个($b、$d、$e)[例如。通过 apache mod] 或 fpm 直接,但如果从 cli 运行,则所有 5 个。
这是为什么?有人知道这种不一致吗?
<?php
error_reporting(-1);
ini_set("display_errors", 1);
$b==1;
if($c);
if ($d==1);
(int) $e;
(boolean) $f;
下面是示例转储,来自我的一个朋友
$ cat v.php
<?php
$a;
$b==1;
if($c);
if ($d==1);
(int) $e;
(boolean) $f;
$ cat v.sh
#!/bin/bash
SCRIPT_FILENAME=`pwd`/v.php \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect /var/run/php5-fpm.sock
$ php v.php
PHP Notice: Undefined variable: b in /tmp/fpm-test/v.php on line 3
PHP Notice: Undefined variable: c in /tmp/fpm-test/v.php on line 4
PHP Notice: Undefined variable: d in /tmp/fpm-test/v.php on line 5
PHP Notice: Undefined variable: e in /tmp/fpm-test/v.php on line 6
PHP Notice: Undefined variable: f in /tmp/fpm-test/v.php on line 7
$ ./v.sh
PHP message: PHP Notice: Undefined variable: b in /tmp/fpm-test/v.php on line 3
PHP message: PHP Notice: Undefined variable: d in /tmp/fpm-test/v.php on line 5
PHP message: PHP Notice: Undefined variable: e in /tmp/fpm-test/v.php on line 6
X-Powered-By: PHP/5.5.9-1ubuntu4.3
Content-type: text/html