Constants in class definitions

From: Date: Tue, 24 Feb 2004 00:22:29 +0000
Subject: Constants in class definitions
Groups: php.general 
Request: Send a blank email to php-general+get-178616@lists.php.net to get a copy of this message
Hi all. I was wondering if using defined constants in class definitions is completely legal (or even good practice) in PHP. For example, <?php define( "CONSTANT", "hello" ); class Yep{ $var stuff = array( CONSTANT => 'two' ); } ?> I've looked throught the PHP documentation and from what I can tell it is legal. I'm using PHP4.3.4, and haven't had any problems with class definitions like this. However, I've had some problems with Turck MMCache and class definitions that are similar to above. I suspect that it's probably a bug with MMCache but I wanted to check to make sure that the code was completely correct. The following seems to work fine with MMCache, <?php define( "CONSTANT", "hello" ); class Yep{ $var stuff = NULL; function Yep(){
     $this->stuff = array( CONSTANT => 'two' );
} } ?> If it turns out that the first example is fine, then I'll look a submitting a bug for MMCache. Thanks Toro ##################################################################################### This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal For more information please visit www.marshalsoftware.com #####################################################################################

« previous php.general (#178616) next »