我收到如下错误:
Parse error: syntax error, unexpected '(', expecting ',' or ';' in X:\xampp\htdocs\lib.php on line 15
当我尝试将日期保存到变量时。这是我的代码......(PHP)
protected $title = date('D, d M Y');
答案 0 :(得分:2)
您应该在构造函数中设置属性默认值:
class Something
{
protected $title;
public function __construct()
{
$this->title = date('D, d M Y');
}
}