在下面的代码中,我们可以看到使用未定义变量的5个示例。 有了错误报告和显示,我们应该看到5个通知。 但是,在PHP 5.5中,当使用“http解释器”时,我们将只看到其中的3个($ b,$ d,$ e)[例如。通过apache mod]或fpm直接但是所有5个如果从cli运行。
为什么?有没有人知道这种不一致的事情?
<?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