【发布时间】:2012-04-22 22:29:26
【问题描述】:
以下不起作用:
<?php
class test{
const t = 10;
public static $y = array('t' => self::t . 'hello');
}
var_dump(test::$y);
?>
谁能告诉我这是为什么? :)
它在 ... => self::t 中失败。 'hello')... 部分,作为接缝,它不能在 array() 中连接一个类常量。
这意味着以下两种情况都很完美:
public static $y = array('t' => self::t);
和
public static $y = array('t' => 'hello');
【问题讨论】:
-
总是添加你的错误信息。如果你把它粘贴到搜索框中,你会得到 ca。 999 个相似的问题,即使不完全一样。
标签: php arrays class-constants