为您未来的自己节省大量工作,并找到另一个更直观的解决方案:
这是我希望能够做到的:
class Test {
public static $test = 'boo';
}
class Two extends Test {
public static $test = parent::$test.'hoo';
}
// Two::$test == 'boohoo'
好吧,特别是组合两个数组,但这里说明了它。
有可能吗?
这是不可能的,因为在声明变量时不能求值。
类似:
class A {
$seconds_in_a_day = 60*60*24; // invalid
$seconds_in_a_day2 = 86400; // sour but valid
}
是无效的
你可以把它移到构造函数中。
public function __construct() {
self::$test = parent::$test.'hoo';
}
除了所有这些…千万别这么做。P