note 86250 modified in language.oop5.autoload by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.