Analyze every function I call
I want to analyze t开发者_运维百科he result of each function that I call. If this result is a exception or is false then the script ends. I can do this manually, but it is a big waste of time to call a control function for each new function.
Can I configure PHP to set this error function automatically?
Check the comments , will give you and idea of how to register callbacks .
How do I catch a PHP Fatal Error
Here are some steps I ll suggest :
a) register register_shutdown_function or other callback functions to track your exceptiosn
b) Each function call Should throw an exception when there is error
c) call_back function catches the exception
d) echo custom output
check my comment on above reference question
You mean the call_user_func and call_user_func_array functions?
function error ($funcName, $funcParameter) {
try {
$params = func_get_args();
unset($params[0]);
call_user_func_array($funcName, $params) or exit ("Error !");
}
catch (exception $e) {
exit ("Error !");
}
}
精彩评论