Re: Re: some kind of "library loader"

From: Date: Wed, 03 Apr 2002 21:58:31 +0000
Subject: Re: Re: some kind of "library loader"
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91427@lists.php.net to get a copy of this message
On Wed, 3 Apr 2002, Tamás Árpád wrote: > >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 (#91427) next »