日期中出现意外错误


Unexpected error in date?

我收到如下错误:

Parse error: syntax error, unexpected '(', expecting ',' or ';' in X:'xampp'htdocs'lib.php on line 15

当我尝试将日期保存到变量时。 这是我的代码...(菲律宾比索)

protected $title = date('D, d M Y');

您应该在构造函数中设置属性默认值:

class Something
{
    protected $title;
    public function __construct()
    {
        $this->title = date('D, d M Y');
    }
}