clsystems / php-filter
Php Input Filter package
Installs: 58
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:php
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-10-29 05:53:36 UTC
README
Installation via Composer
{ "require": { "clsystems/php-filter": "~1.0" } }
Alternatively, from the command line:
composer require clsystems/php-filter
Usage
use CLSystems\Php\Filter; // Syntax Filter::clean($source, $type); // Example $source = '<h1>Hello World!</h1>'; // Return 'Hello World!' $filtered = Filter::clean($source, 'string'); // Source array $source = [ '<h1>Hello World!</h1>', '<h1>Hello VietNam!</h1>', ]; // Return ['Hello World!', 'Hello VietNam!'] $filtered = Filter::clean($source, 'string'); // Multi-type $source = ' <h1>Hello World!</h1> '; // Return 'Hello World!' $filtered = Filter::clean($source, ['string', 'trim']);
Filter types
- int
- uint (unsigned int)
- float
- ufloat (unsigned float)
- boolean
- alphaNum (alpha numeric string)
- base64
- string (no HTML tags)
- url
- slug (url alias without slash)
- path (url alias with slash)
- unset (return NULL value)
- jsonEncode
- jsonDecode
- yesNo (return 'Y' or 'N')
- inputName (regex /[^a-zA-Z0-9_]/)
- unique (array unique)
- basicHtml
Fallback default
if (function_exists($type)) { if (is_array($value)) { $result = array_map($type, $value); } else { $result = $type($value); } } else { $result = $value; }