Hello I have a code like that :
try
{
// Here I call my external function
do_some_work()
}
catch(Exception $e){}
The question is: If the do_some_work() has a problem and produce an Error this try catch will hide the error?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are two types of error in PHP. There are exceptions, and there are errors.
try..catchwill handle exceptions, but it will not handle errors.In order to catch PHP errors, you need to use the
set_error_handler()function.One way to simplify things mught be to get
set_error_handler()to throw an exception when you encounter an error. You’d need to tread carefully if you do this, as it has the potential to cause all kinds of trouble, but it would be a way to gettry..catchto work with all PHP’s errors.