note 54333 deleted from language.oop5.autoload by felipe

From: Date: Mon, 24 Mar 2008 22:32:13 +0000
Subject: note 54333 deleted from language.oop5.autoload by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137489@lists.php.net to get a copy of this message
Note Submitter: sr at brightlight dot ch ---- I hope this helps some people: <?php function __autoload($name) { $class = $interface = false; // interface first if (include_exists("interface.$name.inc")) { include_once("interface.$name.inc"); $interface = true; } // class later if (include_exists("class.$name.inc")) { include_once("class.$name.inc"); $class = true; } // catch error if ($class === false && $interface === false) { trigger_error("Failed to include class/interface $name", E_USER_WARNING); return false; } return true; } function include_exists($file) { static $include_dirs = null; static $include_path = null; // set include_dirs if (is_null($include_dirs) || get_include_path() !== $include_path) { $include_path = get_include_path(); foreach (split(PATH_SEPARATOR, $include_path) as $include_dir) { if (substr($include_dir, -1) != '/') { $include_dir .= '/'; } $include_dirs[] = $include_dir; } } if (substr($file, 0, 1) == '/') { //absolute filepath - what about file:///? return (file_exists($file)); } if ((substr($file, 0, 7) == 'http://' || substr($file, 0, 6) == 'ftp://') && ini_get('allow_url_fopen')) { return true; } foreach ($include_dirs as $include_dir) { if (file_exists($include_dir.$file)) { return true; } } return false; } ?>

« previous php.notes (#137489) next »