php: try-catch not catching all exceptions
Solution #1
Use ErrorException to turn errors into exceptions to handle:
function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, $errno, 0, $errfile, $errline);}set_error_handler("exception_error_handler");
Solution #2
try { // just an example $time = 'wrong datatype'; if (false === $timestamp = date("Y-m-d H:i:s", $time)) { throw new Exception('date error'); }} catch (Exception $e) { return false;}