Several options:
Suppress all errors for just this function call
@$doc->load('http://twitter.com/statuses/user_timeline/1234567890.rss');
which is the same as
$oldLevel = error_reporting(0);
$doc->load('http://twitter.com/statuses/user_timeline/1234567890.rss');
error_reporting($oldLevel);
Suppressing errors this way is generally frowned upon, as it makes code harder to debug. Like Shrapnel pointed out, you want to disable public display of all error messages on a production system anyway. On Dev systems you are encouraged to use error_reporting(-1);
, which would enable E_ALL
and E_STRICT
.
If you want to use try/catch
, you can also change default error handling and convert all errors to exceptions by doing
function myErrorHandler($errno, $errstr, $errfile, $errline) {
throw new Exception($errstr, $errno);
}
set_error_handler("myErrorHandler");
This is a global change though and affects everything raised. You'd also have to use catch(Exception $e)
instead of Zend_Exception
then in your code, but it would work. Note that the above would convert everything, even Notices, so you will also get an Exception about $isOk
being undefined if you are trying to access this later. Feel free to adapt the handler to your liking and check out the user comments for set_error_handler
for more refined versions.
Another global change would be to change the application.ini in your application folder, e.g. letting Zend Framework control error handling:
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
Change these to your needs. They are the same as in PHP.ini, e.g.
display_errors:
This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user.
display_startup_errors:
Even when display_errors is on, errors that occur during PHP's startup sequence are not displayed. It's strongly recommended to keep display_startup_errors off, except for debugging.