1. Go to this page and download the library: Download initphp/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/ */
initphp / validation example snippets
use InitPHP\Validation\Validation;
// GET /?name=Muhammet&year=2022
$validation = new Validation($_GET);
$validation->rule('name', 'reach ($validation->getError() as $message) {
echo $message . "\n";
}
}
$validation = new Validation(['number' => 13]);
$validation->rule('number', static function ($value): bool {
return ($value % 2) === 0;
}, '{field} must be an even number.');
$validation->validation(); // false
$validation->getError(); // ["number must be an even number."]