Re: what's the point of _autoload?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 14, 2010 at 7:31 AM, Michael N. Madsen <mnm@xxxxxxxxxx> wrote:

> 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!)
>

umm ok ill correct you.., theres no requirement to have files in a single
directory.  php gives you the name of a class and you are responsible for
finding the file where the class lives and load it.


> 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.


actually, autoloading typically reduces load on the server b/c only the
files you actually need for a given request are loaded on demand.  this in
contrast to requires/includes for every possible class that could
potentially be needed to fulfill a given request.


> 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?


see above; its a speed boost, and typically folks prefer not to bother
include/require files atop ever class the define; those are the 2 main
benefits.

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux