note 86477 deleted from language.oop5.autoload by danbrown

From: Date: Tue, 11 Oct 2011 20:00:30 +0000
Subject: note 86477 deleted from language.oop5.autoload by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183823@lists.php.net to get a copy of this message
Note Submitter: lskatz at gmail dot com ---- Building on Chris Continanza's function, I wanted to add in multiple filename options since sometimes I add ".class.php" and other times ".php". <?php function __autoload($class_name) { $include_path = get_include_path(); $include_path_tokens = explode(':', $include_path); foreach($include_path_tokens as $prefix){ $path[0] = $prefix . '/' . $class_name . '.php'; $path[1]= $prefix . '/' . $class_name . '.class.php'; foreach($path as $thisPath){ if(file_exists($thisPath)){ require_once $thisPath; return; } } } } ?>

« previous php.notes (#183823) next »