PHP 8.5.0 Beta 1 available for testing

Voting

: eight minus four?
(Example: nine)

The Note You're Voting On

vernon at kesnerdesigns dot net
18 years ago
In response to seejohnrun's version to check if a URL exists. Even if the file doesn't exist you're still going to get 404 headers. You can still use get_headers if you don't have the option of using CURL..

$file = 'http://www.domain.com/somefile.jpg';
$file_headers = @get_headers($file);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
$exists = false;
}
else {
$exists = true;
}

<< Back to user notes page

To Top