note 76427 modified in function.file-exists by bjori

From: Date: Sun, 15 Jul 2007 09:23:22 +0000
Subject: note 76427 modified in function.file-exists by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-128536@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); } @+ --was-- /* * 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); } @+ http://php.net/manual/en/function.file-exists.php

« previous php.notes (#128536) next »