我在OS X El Capitan上运行PHP版本7.0.2,每次执行包含一些错误代码的PHP脚本时,它都会报告错误,然后似乎自动执行回溯。 我不太确定这是否是PHP 7中的新功能,但我似乎无法在任何地方或其他遇到类似问题的人中找到它。
例如:
<?php echo $a; ?>如果从CLI执行,将返回以下输出:
PHP Notice: Undefined variable: a in /Path/to/file.php on line 2 PHP Stack trace: PHP 1. {main}() /Path/to/file.php:0 Notice: Undefined variable: a in /Path/to/file.php on line 2 Call Stack: 0.0002 350944 1. {main}() /Path/to/file.php:0任何可能导致问题的见解都是受欢迎的。 谢谢。
I'm running PHP version 7.0.2 on OS X El Capitan and every time I execute a PHP script that contains some erroneous code, it reports the error and then seems to perform a backtrace automatically. I'm not so sure if this is a new feature in PHP 7, however I cannot seem to find mention of it anywhere or anyone else who's facing a similar problem.
For Example:
<?php echo $a; ?>Will return the following output if executed from CLI:
PHP Notice: Undefined variable: a in /Path/to/file.php on line 2 PHP Stack trace: PHP 1. {main}() /Path/to/file.php:0 Notice: Undefined variable: a in /Path/to/file.php on line 2 Call Stack: 0.0002 350944 1. {main}() /Path/to/file.php:0Any insight on what might be causing the problem is welcome. Thanks.
最满意答案
我面临的问题不在于PHP 7.0.2本身,而是在某种程度上被称为XDebug的扩展。 用于高级错误报告的XDebug在我的另一个项目中引起了问题,并且通过禁用它,它似乎解决了我的问题。 要禁用XDebug,您需要做的就是修改php.ini文件并将值debug.remote_autostart,debug.default_enable和debug.remote_enable从'on'更改为'off'。
The problem I was facing was not with PHP 7.0.2 itself, but with an extension that had somehow become enabled called XDebug. XDebug which is intended for advanced error reporting was causing problems in another project of mine and by disabling it, it seemed to solve my problem. In order to disable XDebug all you need to do is modify your php.ini file and change the values debug.remote_autostart, debug.default_enable, and debug.remote_enable from 'on' to 'off'.
更多推荐
发布评论