-2
这是我的代码:在php类中变量是一个等于二的变量?
class Config {
static public $site = 'http://localhost/site/';
static public $style = $site . 'css/style.css';
// ...
}
这不是为我工作。我得到白色屏幕。
class Config {
static public $site = 'http://localhost/site/';
static public $style = 'http://localhost/site/css/style.css';
// ...
}
这是工作。我得到设计和代码。工作得很好。我的问题是为什么?
你能回应'$ style'并与我们分享吗? – Mureinik
[PHP文档](http://php.net/manual/en/language.oop5.properties.php) - '这个声明可能包含一个初始化,但是这个初始化必须是一个常量值 - 也就是说,它必须能够在编译时进行评估,并且不能依赖运行时信息进行评估。“....任何非常量值的串联,其性质是运行时评估 –
也不会$网站。 'css/style.css';''无论如何都是有效的;它需要是'self :: $站点。 'css/style.css';' –