Re: what's the point of _autoload?

From: Date: Fri, 14 May 2010 13:39:14 +0000
Subject: Re: what's the point of _autoload?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-305204@lists.php.net to get a copy of this message
I use this in a different way so I think it can be useful for everyone avoiding long and complex codes. I´ve got a file called classes.php that looks like: <?php $Classes = new stdClass(); $Classes->Smarty = BASE_PATH."includes/Smarty/Smarty.class.php"; $Classes->Mail = BASE_PATH."includes/mail/Mail.php"; ?> So my _autoload() looks like: function MY__autoload($className) { require_once("classes.php") require_once($Classes->$className); } if (function_exists("spl_autoload_register") ) { spl_autoload_register("MY__autoload"); } else { function __autoload($className) { MY__autoload($className); } } Hope it can help you. ""Michael N. Madsen"" <mnm@criion.net> escreveu na mensagem news:62.43.44964.9B05DEB4@pb1.pair.com... > Since php started to support oop it has moved more and more features in > that direction. > This is good for me because I love oop. Then came _autoload() and I was > rejoiced only to find that this (no fun)ction can't be used to it's > fullest potential in oop unless I have all the files in the same > directory. This is where you correct me and tell me how I can have a file > structure in more then one level and still get the ripe juices of > _autoload() (Please, I beg you!) > > I have looked at the comments on the doc page of the function and every > single one comes with the addition of many, often complex lines of code > that will only add more load on the server. If _autoload can't figure out > the correct path to the file which defines the class, then what is the > point from an oop pov?

« previous php.general (#305204) next »