0

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.

Can I configure PHP to set this error function automatically?

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Caio
  • 3,178
  • 6
  • 37
  • 52
  • 1
    I don't quite understand what you are trying to do, but you are aware of http://www.php.net/set_error_handler? – Pekka Feb 24 '10 at 23:54
  • There's some similar things you could do. But, you really should give a bit more detail about why you would want to do such an odd thing. Are you debugging? There's better ways. Is this going to be a real part of an actual script? There's better ways. – goat Feb 25 '10 at 01:10

2 Answers2

1

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

Community
  • 1
  • 1
sakhunzai
  • 13,900
  • 23
  • 98
  • 159
0

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
  • 9,833
  • 3
  • 32
  • 41