Re: Re: some kind of "library loader" - Thanks

From: Date: Thu, 04 Apr 2002 08:33:36 +0000
Subject: Re: Re: some kind of "library loader" - Thanks
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91497@lists.php.net to get a copy of this message
Ok, Thank you for your help Miguel and Maxim, I'm trying to do it by the help of your suggestions. Arpi > > >Also, you can find out if a class was defined by calling > > >'class_exists()'. In this way you might save something. > > >The best way thought is what Miguel was saying: load the files > > >conditionally with a logic. > > > > That's what I'm trying to do, but still searching for the logic. > > But as I see, there's no better way of doing this other than > > checking if the needed classes are defined before every > > instantiation. > > Perhaps you can conjure up some sort of namespace scheme, and then > use a global array to track which class files have been loaded, or > which classes have been instantiated, or whatever it is you need to > keep track of. > > In your file with a dependency: > > global $LOAD_STATUS; > if (!$LOAD_STATUS['classes-db-queryops']) > include 'lib/classes/db/queryops.php'; > > In lib/classes/db/queryops.php: > > global $LOAD_STATUS; > $LOAD_STATUS['class-db-queryops'] = 1; > > Seems fairly cheap to do. > > miguel

« previous php.general (#91497) next »