PHP code example of fangstar / php-validator
1. Go to this page and download the library: Download fangstar/php-validator 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/ */
fangstar / php-validator example snippets
file check
bash
$ composer
php
use FangStarNet\PHPValidator\Validator;
$data = $_GET;
Validator::make($data, [
"id" => "present|alpha_num|length:32", // 校验id字段必传,且由数字字母组成,长度为32
]);
if (Validator::has_fails()) {
echo Validator::error_msg(); // 校验不通过,打印提示信息(默认使用语言包中的文案)
exit;
} else {
echo "参数校验已经通过";
}