PHP4: Constant inside a class
This gives me PHP Parse error: syntax error, unexpected ';', expecting '(' in C:\Program Files\Apache Group\Apache2\htdocs\toolmon\_debug_tmp.php on line 15 having a code
Code:
class test {
var $SOME_CONST = 10;
}
echo test::$SOME_CONST;
:( Can't I create a constant variable inside a class?
Thanks.
Re: PHP4: Constant inside a class
I don't think so, only instance variables. Constants are static.
Re: PHP4: Constant inside a class
Quote:
Originally Posted by nebulom
This gives me
PHP Parse error: syntax error, unexpected ';', expecting '(' in C:\Program Files\Apache Group\Apache2\htdocs\toolmon\_debug_tmp.php on line 15 having a code
Code:
class test {
var $SOME_CONST = 10;
}
echo test::$SOME_CONST;
:( Can't I create a constant variable inside a class?
Thanks.
I suggest you do what most other packages do:
PHP Code:
define('CLASSNAME_CONST_NAME', 1);
Its not a class constant but it signifies its relation to the class. I also suggest you upgrade to PHP 5 ;)
Re: PHP4: Constant inside a class
Hehe. Will do upgrade soon. Thanks.