概要
令人惊讶的是,我在谷歌或其他网站上找不到任何内容。当我在PHP中抛出异常时,它会出现在我的控制台中两次,其中包含错误消息和堆栈跟踪。它第一次打印它说“PHP致命错误:…”,第二次它只是说“致命错误:…”。我没有测试过这是Apache插件版本。
例
为了安全起见,使用“…”缩短了一些命名空间和路径
$ php code/com/.../tabular_data.php
PHP Fatal error: Uncaught exception 'Exception' with message 'File type not supported' in /home/codemonkey/.../tabular_data.php:56
Stack trace:
#0 /home/codemonkey/.../tabular_data.php(88): com\...\Tabular_Data->loadFromFile('/home/codemonke...', false)
#1 /home/codemonkey/.../tabular_data.php(95): com\...\Tabular_Data::fromFile('/home/codemonke...')
#2 {main}
thrown in /home/codemonkey/.../tabular_data.php on line 56
Fatal error: Uncaught exception 'Exception' with message 'File type not supported' in /home/codemonkey/.../tabular_data.php:56
Stack trace:
#0 /home/codemonkey/.../tabular_data.php(88): com\...\Tabular_Data->loadFromFile('/home/codemonke...', false)
#1 /home/codemonkey/.../tabular_data.php(95): com\...\Tabular_Data::fromFile('/home/codemonke...')
#2 {main}
thrown in /home/codemonkey/.../tabular_data.php on line 56
题
我认为它与stderr和stdout有关,打印错误。在任何情况下,如何请求PHP很好地打印一次,最好是stderr?
版本输出
PHP 5.3.9(cli)(内置:2012年1月11日17:09:48)
版权所有(c)1997-2012 PHP集团
Zend Engine v2.3.0,版权所有(c)1998-2012 Zend Technologies
代码
http://pastebin.com/iBUGJ2eY
这是为我显示双重异常的确切代码,命名空间和路径编辑为foos。请注意,我总是在此安装的命令行中获得双重异常。我只能确定问题在于PHP配置。