note 86250 modified in language.oop5.autoload by danbrown

From: Date: Thu, 09 Oct 2008 15:41:27 +0000
Subject: note 86250 modified in language.oop5.autoload by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145214@lists.php.net to get a copy of this message
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; } ?> --was-- A simple way to autoload all classes [code] 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; } [/code] http://php.net/manual/en/language.oop5.autoload.php

« previous php.notes (#145214) next »