You are here: Re: [PHP] PHP 5 Question about OO « PHP « IT news, forums, messages
Re: [PHP] PHP 5 Question about OO

Posted by "Richard Lynch" on 06/02/05 05:00

On Wed, June 1, 2005 3:53 am, Marcus Bointon said:
> On 1 Jun 2005, at 11:38, Jochem Maas wrote:
>
>> all true, now imagine that you install a couple of 3rdparty php5
>> 'packages'
>> and they all define __autoload() - ain't gonna work! which is why
>> there has been
>> discussion on internals regarding the possibility of use a handler-
>> function stack
>> for autoloading (in the same way that you can register a stack of
>> input/output
>> filter-function)... something to keep an eye on in case things
>> change :-)
>
> I've run into this one. One way that would work for me (and initially
> it's how I assumed it worked) is for __autoload to be a standard
> class method like __construct, so that a class would attempt to run
> its own autoloader before breaking out to the global function namespace.

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

That seems like classic chicken/egg situation to me...

It's also incredibly likely that __autoload's being "stacked" won't work
out too well.

Consider this:

foo software defines an __autoload
Some foo_* classes get defined, autoloaded, everybody's happy.
bar software defines an __autoload
Some bar_* classes get defined, autoloaded, everybody's happy.
Now some foo_* classes try to get instantiated, for whateve reason.
bar's __autoload function is gonna kick, and that ain't good for foo_*

Seems to me you'd need an array of regular expressions and the function to
call:

array('foo_*'=>'foo__autoload', 'bar_*'=>'bar__autoload')

if you wanted to allow multiple __autoload functions to exist...

I'm sure there are other ideas/solutions floating around, but that's A
possibility.

For performance, maybe just use stristr and 'foo_' instead of RegEx and
'foo_*' [shrug]

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация