PHP隐藏致命错误消息并重定向

If the following code returns a fatal error, I get a message on the page I don't want users to see. I want to hide the fatal error message and redirect the user to another page:

$jinput = JFactory::getApplication()->input;

To hide the error message, I just added:

error_reporting(E_NONE);

But how do I catch and redirect a fatal error like this?

Basicaly, you can't "catch" fatal errors because they stop program execution. But there is one method to handle them. Register your own shutdown handler and check if last error was fatal.

<?php
function shutdownHandler()
{
    $error = error_get_last();
    if ($error['type'] == E_ERROR) {
        your code goes here;
    }
}
register_shutdown_function('shutdownHandler');

Demo: https://eval.in/137869

Like many other PHP users you are confusing error_reporting option with display errors. You need the latter one.

 ini_set('display_errors', 0);

is what you actually need. While error reporting must remains always E_ALL