将静态变量与父级结合起来
这就是我希望能够做到的:
class Test {
public static $test = 'boo';
}
class Two extends Test {
public static $test = parent::$test.'hoo';
}
// Two::$test == 'boohoo'
嗯,特别是组合 2 个数组,但这说明了这一点。
是否可以?
This is what I'd like to be able to do:
class Test {
public static $test = 'boo';
}
class Two extends Test {
public static $test = parent::$test.'hoo';
}
// Two::$test == 'boohoo'
Well, specifically combining 2 arrays, but this illustrates it.
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是不可能的,因为在声明变量时无法评估任何内容。
类似:
甚至无效。
您可以将其移至构造函数。
除此之外..只是不要这样做。为未来的自己节省大量工作并找到另一个更直观的解决方案:P
This isn't possible because you can't evaluate anything when declaring a variable.
Something like:
is invalid even.
You can move it to the constructor.
Aside from all that .. just don't do it. Save your future self a lot of work and find another more intuitive solution :P