note 90588 added to language.oop5.autoload

From: Date: Wed, 29 Apr 2009 16:22:33 +0000
Subject: note 90588 added to language.oop5.autoload
Groups: php.notes 
Request: Send a blank email to php-notes+get-154008@lists.php.net to get a copy of this message
Hi, To include all classes from differents directories, you can specify the path in the name of class.The replace a caracter of your choice by '/'. Here I used "_". ex : the class : dir1_dir2_myclass.class.php will be in dir1/dir2/ <?php function __autoload($className) { $fullclasspath=""; // get separated directories $pathchunks=explode("_",$className); //re-build path without last item for($i=0;$i<(count($pathchunks)-1);$i++) { $fullclasspath.=$pathchunks[$i].'/'; } require_once '../../'.$fullclasspath.$className.'.class.php'; } ?>* bye CasualWeb ---- Server IP: 213.246.51.26 Probable Submitter: 93.9.158.109 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php Edit -- https://master.php.net/note/edit/90588 Del: integrated -- https://master.php.net/note/delete/90588/integrated Del: useless -- https://master.php.net/note/delete/90588/useless Del: bad code -- https://master.php.net/note/delete/90588/bad+code Del: spam -- https://master.php.net/note/delete/90588/spam Del: non-english -- https://master.php.net/note/delete/90588/non-english Del: in docs -- https://master.php.net/note/delete/90588/in+docs Del: other reasons-- https://master.php.net/note/delete/90588 Reject -- https://master.php.net/note/reject/90588 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#154008) next »