Assigning const value to const error in php
<?php
class Lala {
const a = "a";
const b = a . "b";
}
?>
Parse error: syntax error, unexpected '(', expecting ',' or 开发者_开发知识库';' on line 4
What's the problem with it?
From the documentation:
The value must be a constant expression, not (for example) a variable, a property, a result of a mathematical operation, or a function call.
See http://www.php.net/manual/en/language.oop5.constants.php
mb
<?php
class Lala {
const A = "a";
const B = self::A . "b";
}
?>
精彩评论