Say I have a class with a constant in it. I also have a variable in
that class that I would like to set to that constant as the
initialization value. Why doesn't the following work?
class Square
{
const DEFAULT_SIZE=5;
var $size=self::DEF AULT_SIZE; // how do i set $size to DEFAULT_SIZE?
}
$r= new Square();
Errors are:
PHP Fatal error: Cannot access self:: when no class scope is active in
C:\src\test\con sttest.php on line 9
Fatal error: Cannot access self:: when no class scope is active in
C:\src\test\con sttest.php on line 9
Which is wrong, because a class scope is active!! I think it is trying
to inline the code, and it is doing it incorrectly.
-d
Comment