I\'m trying to use file_get_contents
together with stream_context_create
to make POST requests. My code so far:
$options = arra
Adding few more lines to the accepted response to get the http code
function getHttpCode($http_response_header)
{
if(is_array($http_response_header))
{
$parts=explode(' ',$http_response_header[0]);
if(count($parts)>1) //HTTP/1.0
return intval($parts[1]); //Get code
}
return 0;
}
@file_get_contents("http://example.com");
$code=getHttpCode($http_response_header);
to hide the error output both comments are ok, ignore_errors = true or @ (I prefer @)