【发布时间】:2017-01-22 18:54:31
【问题描述】:
这是我的代码:
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并与我们分享吗? -
PHP Docs -
This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated..... 任何非常量值的串联,就其本质而言,都是运行时评估 -
$site . 'css/style.css';`` be valid anyway; it would need to beself::$site 也不会。 'css/style.css';`
标签: php