note 76427 added to function.file-exists
| From: | openspecies at osu1 dot php dot net | Date: | Sat, 14 Jul 2007 20:07:26 +0000 |
| Subject: | note 76427 added to function.file-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128528@lists.php.net to get a copy of this message | ||
/*
* EXTERN/LOCAL FILE
* a simple alternative without cURL
*/
function sys_file_exists($f = NULL)
{
$h = array();
$ret = FALSE;
if(!is_null($f)):
if(preg_match('/^http|https|ftp/',$f)):
$h = @get_headers($f);
if(array_key_exists(0,$h)) :
$ret = (bool) preg_match('/200|301/',$h[0]); /* HTTP/1.1 301 DAP (directory) */
endif;
else:
$ret = (file_exists($f) && is_readable($f));
endif;
endif;
return (($ret === TRUE) ? TRUE : FALSE);
}
@+
----
Server IP: 217.174.196.197
Probable Submitter: 81.57.229.223
----
Manual Page -- http://www.php.net/manual/en/function.file-exists.php
Edit -- https://master.php.net/note/edit/76427
Del: integrated -- https://master.php.net/note/delete/76427/integrated
Del: useless -- https://master.php.net/note/delete/76427/useless
Del: bad code -- https://master.php.net/note/delete/76427/bad+code
Del: spam -- https://master.php.net/note/delete/76427/spam
Del: non-english -- https://master.php.net/note/delete/76427/non-english
Del: in docs -- https://master.php.net/note/delete/76427/in+docs
Del: other reasons-- https://master.php.net/note/delete/76427
Reject -- https://master.php.net/note/reject/76427
Search -- https://master.php.net/manage/user-notes.php