does PHP 5.3 change the way file_get_contents works?

Posted by ceejayoz on Stack Overflow See other posts from Stack Overflow or by ceejayoz
Published on 2010-05-05T15:27:56Z Indexed on 2010/05/05 15:48 UTC
Read the original article Hit count: 349

Filed under:
|
|

I'm having an odd issue with PHP's file_get_contents.

In the past, file_get_contents on a remote file returns the text of that file regardless of the HTTP status code returned. If I hit an API and it sends back JSON error information with a status of 500, file_get_contents gives me that JSON (with no indication that an error code was encountered).

I've just set up a Ubuntu 10.04 server, which is the first Ubuntu to have PHP 5.3. Instead of giving me the JSON, PHP throws a warning when a 500 error is present. As a result, I can't parse the JSON and give a nice error message.

It's nice that PHP is noticing there's an error in the remote file, but I need the JSON even (especially!) if there's a 500 error. There doesn't appear to be any way to switch this off. Has anyone encountered this? Any tips?

© Stack Overflow or respective owner

Related posts about php5.3

Related posts about file-get-contents