Created
September 9, 2018 00:07
-
-
Save davidraedev/7973d909f224266807c692e8afc5e872 to your computer and use it in GitHub Desktop.
php file_get_contents catch error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set_error_handler( | |
create_function( | |
'$severity, $message, $file, $line', | |
'throw new ErrorException($message, $severity, $severity, $file, $line);' | |
) | |
); | |
try { | |
file_get_contents( "www.google.com" ); | |
} catch ( Exception $error ) { | |
echo $error->getMessage(); | |
} | |
restore_error_handler(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment