How to ignore PHP errors?

-3

In Classic ASP I use the statement below at the top of the page:

on error resume next

You will continue to load the page if there is an error in programming ASP on the entire page , without displaying any error messages.

If I want to send a message or stop page processing, I get the error like this:

if Err.Number <> 0 then
    response.write("Estamos com problemas técnicos")
    response.End()
end if

If I do not want to stop loading the page, I do not do the above.

Is there some kind of similar statement in PHP that has the same global effect, that is, that the page loads normally "bypassing" errors without displaying any error by loading the entire page?

    
asked by anonymous 23.12.2017 / 01:54

1 answer

4

Depending on the error, you can use the set_error_handler . With it you can handle certain types of errors, either by displaying, hiding or displaying them.

Another option is to use the error_reporting function. This function is just for that, choose which error to show or want to display.

error_reporting(0) // Desabilita todos os erros
error_reporting(E_ALL) // Habilita todos os erros

But if you want to hide a exception , this is more complicated. You can even make a try..catch or use set_exception_handler , but it is necessary to check what comes after the code to be sure.

try {
  new MyClass($invalidArgument);
} catch (InvalidArgumentException $e) {
  //Ignora
}
    
23.12.2017 / 03:06