note 76380 deleted from function.file-exists by nlopess

From: Date: Fri, 13 Jul 2007 19:03:57 +0000
Subject: note 76380 deleted from function.file-exists by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-128447@lists.php.net to get a copy of this message
Note Submitter: openspecies ---- /* * EXTERN/LOCAL FILE * a simple alternative */ 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 = @preg_match('/200|301/',$h[0]); /* HTTP/1.1 301 DAP */ endif; else: if(preg_match('/^relative:\/\//',$f)) : $f = str_replace('relative://','',$f); endif; $ret = (@file_exists($f) && @is_readable($f)); endif; endif; return (($ret === TRUE) ? TRUE : FALSE); } @+

« previous php.notes (#128447) next »