$data_check['__token__'] = trim($data['__token__']);
$validate = new Validate([
'__token__' => 'require|token'
]);
if (!$validate->check($data_check)) {
dump($validate->getError());
}else{
echo '验证通过';
}
/*
$data_check = trim($data['__token__']);
$result = $this->validate(
[
'__token__' => $data_check
],
[
'__token__' => 'require|token'
]);
if(true !== $result){
// 验证失败 输出错误信息
dump($result);
}else{
echo '验证通过';
}
*/
参考官网手册:https://www.kancloud.cn/manual/thinkphp5/193918