note 86250 deleted from language.oop5.autoload by sthulbourn
| From: | sthulbourn@php.net | Date: | Wed, 14 Jan 2009 20:15:36 +0000 |
| Subject: | note 86250 deleted from language.oop5.autoload by sthulbourn | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149192@lists.php.net to get a copy of this message | ||
Note Submitter: xavierlesa
----
A simple way to autoload all classes
<?php
function autoload($path=false)
{
if(!$path) $path=PATH_MOD;
exec('ls '.$path.'mod_*', $f);
foreach($f as $mod)
{
$module=str_replace('.php','',str_replace($path.'mod_','',$mod));
if(!is_object($this->$module))
{
if(require_once($mod))
{
$this->modulos[$module]=new $module;
$this->module=$this->modulos[$module];
}
else
{
$this->error='error el modulo '.$mod.' no exite, o no tiene permisos';
return false;
}
}
}
return true;
}
?>