03.02.2014 Views

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

HTTP Streams W rapper ” 31<br />

Error H andling<br />

Before <strong>PHP</strong> 5.3.0, an HTTP streams wrapper operation resulting in an HTTP error<br />

response (i.e. a 4xx or 5xx status code) causes a <strong>PHP</strong> -level warning <strong>to</strong> be emitted.<br />

This warning will only contain the HTTP version, the status code, and the status<br />

code description. The function calls for such operations generally return false as a<br />

result and leave you <strong>with</strong>out a stream resource <strong>to</strong> check for more information. H ere’s<br />

an example of ho w <strong>to</strong> get what data you can.<br />

<br />

This situation has been impro ved somewhat in <strong>PHP</strong> 5.3 <strong>with</strong> the addition of the<br />

ignore_errors context setting. When this setting is set <strong>to</strong> true, operations resulting<br />

in errors are treated the same way as successful operations. H ere’s an example of<br />

what that might look like.<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!