Re: PHP 5 Question about OO

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

 



On 2 Jun 2005, at 03:00, Richard Lynch wrote:

Maybe I'm being dumb, but how can an object's __autoload function get
called when the object class definition hasn't been loaded, and that's why
you're calling __autoload in the first place...

It wouldn't solve everything, but it would help. It solves the case where you have a class library that's quite heavily interconnected, and member functions instantiate other classes in that library (a common arrangement in my experience). By having an __autoload method, you get to at least partly avoid global handler clashes by having one that is specific to that library (it would work well in PEAR). If it is in a base class, then you are safe in the knowledge that any class can find any other in the same library, without tripping over anyone else's arrangements. You would still have to deal with the problem of finding the first class (which a global handler may help, subject to the issues that you've already raised), but once that's done, the problem is over. I don't see why they named it __autoload - the __ prefix is usually reserved for special purpose methods, not global functions. Just plain 'autoload' in a global context is not really anything wildly different in style to say ini_set or error_reporting.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus@xxxxxxxxxxxxxxxxxx | http://www.synchromedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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