Coding question re constants etc

From: Date: Thu, 07 Feb 2002 23:07:55 +0000
Subject: Coding question re constants etc
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-4495@lists.php.net to get a copy of this message
Hi I'm putting together a bunch of classes which I imagine will end up simialat the the Science/Chemistry classes in that there will be 6 or so related classes. I suspect though that mine will be more closelyt tied to it'll probably work on an inherited main class. I need to create a number of constants which must be accessible to all classes. Because of their nature I can't use PHP constants as some of them are calculated variables. My thought was to use a constructor in the base class to load all the variables but of course the base constructor won't do it's thing in an extended class. Actually, is there a reason why it's designed that way. Anyway, is it acceptable to use a class method to load those variables or is there a better way? An example is <?php class foo { var $baz; function foo() { $this->baz = "BAZ"; } } class foobar extends foo { function foobar() { foo::foo(); } } $bar = new foobar(); echo $bar->baz; ?> Cheers, Graeme

« previous php.pear.dev (#4495) next »