PHP Get Content of HTTP 400 Response PHP Get Content of HTTP 400 Response php php

PHP Get Content of HTTP 400 Response


You have to define custom stream context (3rd argument of function file_get_contents) with ignore_errors option on.


As a follow-up to DoubleThink's post, here is a working example:

$url = 'http://whatever.com';//Set stream options$opts = array(  'http' => array('ignore_errors' => true));//Create the stream context$context = stream_context_create($opts);//Open the file using the defined context$file = file_get_contents($url, false, $context);