note 19664 deleted from ref.filesystem by felipe

From: Date: Mon, 10 Dec 2007 17:55:05 +0000
Subject: note 19664 deleted from ref.filesystem by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133222@lists.php.net to get a copy of this message
Note Submitter: meheler at canada dot com ---- Here is a useful function that checks for the existance of a file in PHP's include_path: // Searches PHP's include_path variable for the existance of a file // Returns the filename if it's found, otherwise FALSE. // Only works on a *nix-based filesystem // Check like: if (($file = file_exists_path('PEAR.php')) !== FALSE) function file_exists_path($file) { // Absolute path specified if (substr($path,0,1)=='/') return (file_exists($file))?realpath($file):FALSE; $paths = explode(':',ini_get('include_path')); foreach ($paths as $path) { if (substr($path,-1)!='/') $path = "$path/"; if (file_exists("$path$file")) return realpath("$path$file"); } return FALSE; } Mike

« previous php.notes (#133222) next »