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;
$validation = new Validation($_GET);
// GET /?name=Muhammet&year=2022
$validation->rule('name', 'string');
$validation->rule('year', 'integer|range(1970...2099)');
if($validation->validation()){
// ... process
}else{
foreach ($validation->getError() as $err) {
echo $err . "<br />\n";
}
}
use \InitPHP\Validation\Validation;
$validation = new Validation($_GET);
// GET /?number=13
$validation->rule('number', function ($data) {
if(($data % 2) == 0){
return true;
}
return false;
}, "{field} must be an even number.");
if($validation->validation()){
// ... process
}else{
foreach ($validation->getError() as $err) {
echo $err . "<br />\n";
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.