How to catch WARNINGs in PHP?

Is it possible to catch the WARNINGs in PHP, like catching EXCEPTIONs with try and catch block?

I don’t think so.

perhaps you can make an error handler that throws exceptions when he recieves a warning? Never tried it, but could work?

hth :wink:

As of PHP5, yes, you can, with try/catch blocks. Read up on it here at php.net.

Without php5 you don’t have try/catch :wink:

I have already tried try and catch, but it catches only the error exceptions :frowning:

you have a set_error_handler() function that I think is a custom function called when an error is generated in a script.

Might want to check if you can apply that to notices and warnings.

Otherwise, I don’t really see what you can do as you can only hide them or make error handling of the values yourself (usually, you should not have warnings or notices in your code, you should cope with every possible situation and drive the process with error handling)