note 82614 added to language.oop5.autoload

From: Date: Fri, 18 Apr 2008 11:43:16 +0000
Subject: note 82614 added to language.oop5.autoload
Groups: php.notes 
Request: Send a blank email to php-notes+get-138476@lists.php.net to get a copy of this message
Andrew: 03-Nov-2006 12:26 That seems a bit messy to me, this is a bit neater: <?php function __autoload($class_name) { //class directories $directorys = array( 'classes/', 'classes/otherclasses/', 'classes2/', 'module1/classes/' ); //for each directory foreach($directorys as $directory) { //see if the file exsists if(file_exists($directory.$class_name . '.php')) { require_once($directory.$class_name . '.php'); //only require the class once, so quit after to save effort (if you got more, then name them something else return; } } } ---- Server IP: 92.48.100.16 Probable Submitter: 193.128.117.15 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php Edit -- https://master.php.net/note/edit/82614 Del: integrated -- https://master.php.net/note/delete/82614/integrated Del: useless -- https://master.php.net/note/delete/82614/useless Del: bad code -- https://master.php.net/note/delete/82614/bad+code Del: spam -- https://master.php.net/note/delete/82614/spam Del: non-english -- https://master.php.net/note/delete/82614/non-english Del: in docs -- https://master.php.net/note/delete/82614/in+docs Del: other reasons-- https://master.php.net/note/delete/82614 Reject -- https://master.php.net/note/reject/82614 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138476) next »