1
有人可以帮助我对此:声明一个类的内部变量和分配值动态
class Helper_common
{
public static $this_week_start_date = date**(**"Y-m-d", strtotime("previous monday"));
}
当我定义的类里面的变量也给出了日期功能的启动架错误。
有人可以帮助我对此:声明一个类的内部变量和分配值动态
class Helper_common
{
public static $this_week_start_date = date**(**"Y-m-d", strtotime("previous monday"));
}
当我定义的类里面的变量也给出了日期功能的启动架错误。
免费PHP代码是不允许类方法外,你只能写常量表达式。
在一个普通的属性,你可以简单地做它从从构造函数或其他一些方法:
class Helper_common
{
public $this_week_start_date;
public function __construct()
{
$this->this_week_start_date = date("Y-m-d", strtotime("previous monday"));
}
}
但你有一个静态属性。我想不出任何其他的解决方案,除了从类的外部做:
class Helper_common
{
public static $this_week_start_date;
}
Helper_common::$this_week_start_date = date("Y-m-d", strtotime("previous monday"));
它可能会更好重新考虑你的设计。
顺便说一句,下次请发布确切的错误消息,而不是简要说明它;-) –