I have a strange problem with PHP file_get_contents.
In the past file_get_contents, the remote file returned the text of this file regardless of the HTTP status code returned. If I hit the API and sent back JSON error information with a status of 500, file_get_contentsit gives me that JSON (without indicating that an error code was encountered).
I just installed the Ubuntu 10.04 server, which is the first Ubuntu with PHP 5.3. Instead of giving me JSON, PHP gives a warning when a 500 error is present. As a result, I cannot parse the JSON and give a good error message.
It's nice that PHP notices there an error in the remote file, but I need JSON even (especially!) If there is a 500 error. There seems to be no way to disable this. Has anyone come across this? Any tips?
source
share