有什么办法如何丰富php中的错误消息?我得到错误如更好的错误消息为PHP
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 524288 bytes) in /site/lib/Zend/Db/Statement/Pdo.php on line 228
这是不是很好。至少callstack会更有帮助。
有什么办法如何丰富php中的错误消息?我得到错误如更好的错误消息为PHP
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 524288 bytes) in /site/lib/Zend/Db/Statement/Pdo.php on line 228
这是不是很好。至少callstack会更有帮助。
那么PHP错误对我来说很清楚,但是如果你想要非常详细的信息,为什么不写异常类并且定制消息包括异常消息和你自己的细节。
如果你想要更详细的信息,那么有一种方法来拦截函数中的错误信息。在那里你可以抛出一个ErrorException
例如。这会给你更多的细节。
尝试像下面(的catchException
是optoinal虽然)
function exception_error_handler($errno, $errstr, $errfile, $errline)
{
if (error_reporting() === 0)
{
return;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
function catchException($e)
{
// Do some stuff
}
set_exception_handler('catchException');
尝试安装xdebug,看看在various settings ...
什么是不明确的,以你在这个错误?它其实很清楚。您的程序使用的RAM超出允许的范围,并且没有剩余RAM可供使用。为它分配更多的内存。 – 2013-03-13 14:20:43
我认为这个错误信息非常清楚并且非常重要。如果它说:“糟糕,我的日记,你试图记忆太多,那里再试一次,对不起。”只要处理它。要么使脚本减少内存密集程度,要么让它拥有更多的内存。 – 2013-03-13 14:24:30
您可以获得调用堆栈...尝试搜索@ php.net? debug_backtrace http://php.net/manual/en/function.debug-backtrace.php其他的好方法是创建你自己的ExceptionHandlers ...例子在这里:http://www.edmondscommerce.co.uk/php/PHP的自定义错误和异常处理,使-PHP-严格/ – 2013-03-13 14:21:55