How to handle error log in framework
This is sample code t开发者_如何学JAVAo catch error in PHP.
<?php
// Error handler function.
function customError($errno, $errstr)
{
echo "<b>Error:</b> [$errno] $errstr";
}
// Set error handler.
set_error_handler('customError');
// Trigger error.
echo($test);
?>
I am using frameworks. i dont know how to log errors. I tried by giving function customError($errno, $errstr)
in modal and I called from controller it doesn't work for me. How to handle error in frameworks?
The best approach is to throw exception. Inside your main execution loop catch exceptions and output them into log file.
精彩评论