note 76068 added to language.oop5.autoload

From: Date: Thu, 28 Jun 2007 16:46:53 +0000
Subject: note 76068 added to language.oop5.autoload
Groups: php.notes 
Request: Send a blank email to php-notes+get-128057@lists.php.net to get a copy of this message
a static classlist can speed up the autoload in a arbitrary folder structure. each file holds one class with filename = classname + .php <?php define ("CLASS_PATH", "path to your classes"); function __autoload($className) { static $classes = null; if (!$classes) $classes = loadClasses(CLASS_PATH); require_once($classes[$className]); } function loadClasses($path) { $classes = array(); $h = @opendir($path); if ($h) while ($file = @readdir($h)) { if ($file=='.' || $file=='..') continue; if(is_dir($path.$file)) $classes = array_merge($classes, loadClasses($path.$file."/")); else $classes[array_shift(explode(".", $file))] = $path.$file; } return $classes; } ?> ---- Server IP: 81.223.48.75 Probable Submitter: 213.47.53.191 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php Edit -- https://master.php.net/note/edit/76068 Del: integrated -- https://master.php.net/note/delete/76068/integrated Del: useless -- https://master.php.net/note/delete/76068/useless Del: bad code -- https://master.php.net/note/delete/76068/bad+code Del: spam -- https://master.php.net/note/delete/76068/spam Del: non-english -- https://master.php.net/note/delete/76068/non-english Del: in docs -- https://master.php.net/note/delete/76068/in+docs Del: other reasons-- https://master.php.net/note/delete/76068 Reject -- https://master.php.net/note/reject/76068 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128057) next »