Re: Make class only declare once!
| From: | Brian Clark | Date: | Mon, 08 Jan 2001 06:51:47 +0000 |
| Subject: | Re: Make class only declare once! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33197@lists.php.net to get a copy of this message | ||
Hello Diego,
(DF == "Diego Fulgueira") dful@metahogar.com writes:
DF> I haven't try it, but in case PHP doesn't allow to put class
DF> definitions inside an if clause, use the following code instead:
DF> if (!class_exists(string class_name))
DF> {
DF> eval( "
DF> class Foo_BR extends Foo_Bar{
DF> var $Foo= "bar";
DF> var $Bar = "Foo";
DF> }
DF> ");
DF> }
DF> Seems an ungly hack, but it's all I can think of right now.
Of course, you could also just do:
if(!defined('_FOO_'))
{
define('_FOO_', 1);
/* class here */
}
DF> Cheers.
-Brian
--
To be, or not to be, those are the parameters.