开发者

Analyze every function I call

开发者 https://www.devze.com 2022-12-21 00:07 出处:网络
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

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 !");
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消