How to fix this: PHP Unknown: Function create_function() is deprecated

 set_error_handler(create_function(
        '$severity, $message, $file, $line',
        'throw new Exception($message . " in file " . $file . " on line " . $line . ". Debug backtrace: <pre>" . print_r(debug_backtrace(), true) . "</pre>");'
    ));

You could use a anonymous function (new style) but don’t throw an exception inside the error handler because it will not work.

set_error_handler(
    function($errno, $errstr, $errfile, $errline) 
    {
        echo $errstr . " in file " . $errfile . " on line " . $errline . ". Debug backtrace: <pre>" . print_r(debug_backtrace(), true) . "</pre>";
    }
);

// test above to trigger an error...
trigger_error("Test error!", E_USER_WARNING);
Sponsor our Newsletter | Privacy Policy | Terms of Service