note 92171 deleted from function.file-exists by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Jul 2009 01:44:09 +0000 |
| Subject: | note 92171 deleted from function.file-exists by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158214@lists.php.net to get a copy of this message | ||
Note Submitter: mybodya at gmail dot com
----
Hi. I've spent an hour testing, it seems to be the stabe and fastest version
function url_exists($url) {
if(!preg_match('/(((http(s?))|(ftp))\:\/\/)/i', $url))
$url = 'http://'.$url;
$header = @get_headers($url);
return preg_match('/^HTTP(.*)(200|301|302|307)(.*)$/i', $header[0]);
}
PS: see handled 404 requests: http://www.test.de/test.htm