views:

54

answers:

1

Hy guys.

I want to analyze the 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.

Something like this:

http://codeviewer.org/view/code:c5c

Can I configure PHP to set this error function automatically?

Thanks.

A: 

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