You are not getting 404
because the domain does not exist. Try using valid domain. Using http://.@#$%^&*().com
would return failed to open stream: operation failed
while a valid domain would return failed to open stream: HTTP request failed
Please note one is operation failed
and the other HTTP request failed
you can only get HTTP error when there is HTTP request failed
Example
error_reporting(E_ALL);
ini_set("display_errors", "On");
$url = "http://stockoverflow.com/xxxx"; // URL does not exist
$response = @file_get_contents($url);
var_dump($response,$http_response_header);
Output
boolean false
array (size=7)
0 => string 'HTTP/1.1 404 Not Found' (length=22) <--- you get your 404
1 => string 'Content-Type: text/html' (length=23)
2 => string 'Server: Microsoft-IIS/7.5' (length=25)
3 => string 'X-Powered-By: ASP.NET' (length=21)
4 => string 'Date: Wed, 19 Dec 2012 10:26:20 GMT' (length=35)
5 => string 'Connection: close' (length=17)
6 => string 'Content-Length: 1245' (length=20)