note 82614 deleted from language.oop5.autoload by crell
| From: | crell@php.net | Date: | Mon, 04 Apr 2022 16:33:07 +0000 |
| Subject: | note 82614 deleted from language.oop5.autoload by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218052@lists.php.net to get a copy of this message | ||
Note Submitter: james dot dot dot dunmore at gmail dot com
----
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;
}
}
}