开发者

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";
 }
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜