PHP code example of abdulsalamamtech / php-validator
1. Go to this page and download the library: Download abdulsalamamtech/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/ */
abdulsalamamtech / php-validator example snippets
use Abdulsalamamtech\PhpValidator;
// Load composer dependences
//INCLUDE VALIDATOR TO YOUR PROJECT
h";
// INITIALIZE CLASS
$validator = new Validator();
/* VALID INPUT TAKES IN TWO PERAMETERS THE VARABLE
AND THE DATATYPE YOU LOVE TO USE FOR VALIDATION
THIS ALSO RETURN THE EXACT INPUT
*/
$var = $validator->input($var, "text");
/* INPUT ERROR CHECK FOR ANY ERROR
THIS RETURN TRUE/FALSE
*/
$var_error = $validator->inputError();
// COUNT THE NUMBER OF ERROR
$var_count = $validator->inputCount();
// INPUT ERROR MESSAGE GET ALL THE ERROR MESSAGE IN STRING FORMAT
$var_error_message = $validator->inputErrorMessage();
// INPUT ERROR MESSAGE GET ALL THE ERROR MESSAGE IN ARRAY FORMAT
$var_error_message = $validator->inputErrorMessageArray();
// THIS ALSO RETURN THE EXACT INPUT
$value = $validator->output();
/* THIS RETURN VALIDATED INPUT
IT RETURN HTML ENTITIES AND CHARACTERS
THE PARAMETER IS OPTIONAL
*/
$encode_value = $validator->validInput($var);
/* THIS RETURN VALID OUTPUT
IT CONVERT HTML ENTITIES AND CHARACTERS
THE PARAMETER IS OPTIONAL
*/
$decode_value = $validator->validOutput($var);
// YOUR VARABLE
$name = "Abdulsalam Amtech";
// INITIALIZING CLASS
$validator = new Validator();
$name = $validator->input($name, "text");
// CHECK FOR ANY ERROR
if($validator->inputError() === true){
// GET ERROR MESSAGE
echo $validator->inputErrorMessage();
}else{
// YOU CAN INSERT THIS INTO YOUR SQL STATEMENT
$sql_name = $validator->validInput($name);
}
// VARIABLE FROM database
$sql_name = "Abdulsalam Amtech";
// INITIALIZING CLASS
$validator = new Validator();
// YOU CAN DISPLAY THIS VARIABLE ON YOUR HTML PAGE
$name = $validator->validOutput($sql_name);
echo "My name is " . $name;
$var = "";
$type = "";
$types = [
// for text only
[] = "text",
// for number only
[] = "number",
// for email
[] = "email",
// for text and number only
[] = "alphanumeric",
// for text, numbers, and special characters
[] = "varchar",
// for password (+234): this must be pass into valid input and output
[] = "password"
];
// INITIALIZING CLASS
$validator = new Validator();
$input = $validator->input($var. $type);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.