Re: Referencing a "constant" class variable

From: Date: Wed, 06 Oct 2004 20:34:00 +0000
Subject: Re: Referencing a "constant" class variable
Groups: php.general 
Request: Send a blank email to php-general+get-198776@lists.php.net to get a copy of this message
-------------- Original message from "Chris Boget" : -------------- > Parse error: parse error, expecting ','' or > ';'' in > /usr/local/etc/httpd/domains/eazypro.com/interactive/cron_scripts/test/rate_ > version.php on line 9 > > with line 9 being this line: > > var $MyVar = MyEnums::thisVar; > That is because "In PHP 4, only constant initializers for var variables are allowed. To initialize variables with non-constant values, you need an initialization function which is called automatically when an object is being constructed from the class." (from the manual) Whether or not the syntax MyEnums::thisVar is correct and will accomplish what you want when moved into a function is another story. I haven't been paying close attention and am not sure what you are trying to do, but since it appears you want something that is constant, have you thought about using DEFINE?

« previous php.general (#198776) next »