Powerfull PHP Sanitizer for any variable.
If you want to trust the data and make sure an object or array have the keys you need without manually checking each one.
After sanitizing variable it will get passed through a validation proces and return INVALID_DATA() if no data / invalid INVALID_DATA Default answer: null.
- Require once the class
require_once "/parent-folder/sanitize.php";
. - Initialize the class like so
$Sanitizer = new \tloberg\Sanitizer();
. - See examples for how to use the sanitizer here.
-
Raw
No sanitize -
Array
One or multiple filters functions. One function in filter array will run function on all keys in input array -
Object
One or multiple filters functions. One function in filter object will run function on all keys in input object -
Double
Sanitize Double (optional flags: NO_VALIDATION, STRICT) -
Float
Sanitize Float (optional flags: NO_VALIDATION, STRICT) -
Integer
Sanitize Integer (optional flags: NO_VALIDATION, STRICT) -
Boolean
Sanitize Boolean -
String
Sanitize String (optional flags: DENY_NORWEGIAN, NO_TRIM, NO_HTMLSTRIP, ALLOW_QUOTES) -
Filename
Sanitize Filename (optional flags: DENY_NORWEGIAN) -
Filepath
Sanitize Filepath (optional flags: DENY_NORWEGIAN) -
URL
Sanitize URL (optional flags: NO_VALIDATION) -
Email
Sanitize Email (optional flags: NO_VALIDATION) -
Year
Sanitize Year (optional flags: NO_VALIDATION) -
Timestamp
Sanitize Timestamp (optional flags: NO_VALIDATION) -
Date
Sanitize Date (optional flags: NO_VALIDATION) -
DateTime
Sanitize DateTime (optional flags: NO_VALIDATION) -
Custom
Create your own filter
-
Integer
Boolean result if variable provided is numeric. -
Integer (strict)
Boolean result if variable provided is a integer and only integer value. -
Double
Boolean result if variable provided is a double or any other number. -
Double (strict)
Boolean result if variable provided is a double and only double value. -
Float
Boolean result if variable provided is a float or any other number. -
Float (strict)
Boolean result if variable provided is a float and only float value. -
URL
Boolean result if string provided is a valid URL. -
Email
Boolean result if string provided is a valid email address. -
Year
Boolean result if variable provided is 4 numbers. -
Timestamp
Boolean result if variable provided is php timestamp. -
Date Boolean result if string provided is SQL Date -formatted.
-
Datetime
Boolean result if string provided is SQL Datetime -formatted. -
JSON Boolean result if string provided is JSON -formatted.