3
這裏是我的代碼:爲什麼初始化屬性不起作用?
class Log
{
private $mode = config('my.log.mode');
}
但它拋出語法錯誤 ..!爲什麼?怎麼了?
注意到這個作品,以及:
class Log
{
private $mode;
public function __construct()
{
$this->mode = config('my.log.mode');
}
}
好,有什麼意義?
..或PHP 5.6的標量表達式:http://docs.php.net/manual/en/migration56.new-features.php#migration56.new-features.const-scalar-exprs – simon