amattu2 / php-filter
A basic PHP input filter and validation class.
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/amattu2/php-filter
This package is not auto-updated.
Last update: 2025-10-18 09:01:53 UTC
README
This is a PHP class which implements static methods to filter/format unsanitized user input. See below for usage examples and cases. Alternatively, take a look at the index.php file for further examples.
Usage
Include the /src/Filter.php file
require(dirname(__FILE__) . "/src/Filter.php");
Methods
Filter::*input*(string $var)
Remove unprintable characters, HTML entities, and slashes.
Filter::*nonNumeric*(int|string|double|float $var)
Remove non-numeric characters
Filter::*nonAlpha*(mixed $var)
Remove non-alpha (a-zA-Z) characters
Filter::*nonAlphaNumeric*(mixed $var)
Remove non-alphanumeric (a-zA-Z0-9) characters
Filter::*fileName*(string $var)
Replace whitespace characters with a dash (-)
Filter::*number*(int|string $var)
Format a 10 digit phone number (XXX-XXX-XXXX)
Notes
You should always use prepared statements and proper validation on all unsafe input, regardless of using this class or not.