I know you're not supposed to reference other notes, but sincere props to Nick at Innovaweb's comment, for which I base this addition to his idea:
If you use that function, it will return a string, which is great if you are checking for only files that return 404, or 200, or whatnot. If you cast the string value to an integer, you can perform mathematical comparison on it.
For example:
<?php
function get_http_response_code($theURL) {
$headers = get_headers($theURL);
return substr($headers[0], 9, 3);
}
if(intval(get_http_response_code('filename.jpg')) < 400){
}
?>
Rule of thumb is if the response is less than 400, then the file's there, even if it doesn't return 200.