1. Go to this page and download the library: Download wisonlau/validation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wisonlau / validation example snippets
use Wisonlau\Validation\Factory as ValidatorFactory;
方法一:
//验证
$rules = [
'username' => '�码',
];
//初始化工厂对象
$factory = new ValidatorFactory($input, $rules, $attributes);
//判断验证是否通过
if ($factory->success) {
//通过
} else {
//未通过
//输出错误消息
print_r($factory->errors);
}
方法二:
//验证
$rules = [
'name' => ['