At some point I needed to check if an external image existed to be able to display it, at that time I used this:
<?php
$file = 'http://pt.stackoverflow.com';
$file_headers = @get_headers($file);
$position = strpos($file_headers[0], "404");
if ($position == -1) {
echo "o site está online.";
}
?>
I would like to know if there is any other way to get the same result with php.
I do not want to know if the url is actually a url I just want to know if it really exists.