Archive for December, 2011

Suppressing errors in PHP with control operator @

Wednesday, December 7th, 2011

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.

Your are browsing
the Archives of My Beloved PHP for December 2011.
Categories
Archives
Links