目前使用官方推薦的think\Validate和symfony/translation,目前在驗(yàn)證文件中使用trans會(huì)報(bào)錯(cuò)
<?php
namespace app\validate\report;
use think\Validate;
class ReportDetailValidate extends Validate
{
protected $failException = true;
protected $rule = [
'checkId' => 'require|number'
];
protected $message = [
'checkId.require' => trans('checkId_require'),
'checkId.number' => '檢查報(bào)告ID是數(shù)字'
];
}
報(bào)錯(cuò):
PHP Fatal error: Constant expression contains invalid operations in ...
有其他方案實(shí)現(xiàn)嗎?有沒有自動(dòng)優(yōu)雅的使用方式。