- file_get_contents: documentation ( source)
- set_error_handler: documentation ( source)
- http_build_query: documentation ( source)
<?php
class WarningException extends ErrorException
{
}
set_error_handler(function ($errno , $errstr, $errfile, $errline) {
throw new WarningException($errstr, 0, $errno, $errfile, $errline);
}, E_WARNING);
try {
$destination = 'http://badurl/';
$params = array();
$url = $destination . '?' . http_build_query($params);
$response = file_get_contents($url);
} catch (WarningException $e) {
echo "Warning: ", $e->getMessage();
}