Suppressing errors in PHP with control operator @

Errors give valuable information, it’s worth paying attention to.

Sometimes though when parsing content from different sources you can run into errors you can prevent, or you can’t solve.

Reading something into simpleXML that isn’t 100% validated XML, because it’s encoded in ISO-8859 instead of UTF-8.

Then use the PHP one error control operator @.

When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.

Tha comes quite in hand in the following piece of code :


$xml = @simplexml_load_file('rssfeed.xml');

No more errors.

One Response to “Suppressing errors in PHP with control operator @”

  1. internetconnections Says:

    internetconnections…

    […]My Beloved PHP » Blog Archive » Suppressing errors in PHP with control operator @[…]…

Categories
Archives
Links