在验证类里面加上public $uid=Cookie::get('uid')
这句话就会报错 这是为什么?cookie不能这样用吗?
<?php
namespace app\index\validate;
use think\Validate;
use think\facade\Cookie;
class User extends Validate
{
public $uid=Cookie::get('uid');
protected $rule = [
'uid' => 'number|between:1,120',
];
}
兄弟,你这个可不是单纯的错误哦,弹出系统发生错误啦,说明是你的使用就不规范了。
我一般不像你这样赋值,我都是通过构造函数然后this->uid = Cookie::get('uid'),这样赋值。
我不清楚,能不能像你这样赋值。但是你这样是不科学滴。