One of the most amazing strengths of PHP is its convenience. However this has
worked against PHP as numerous coders have forgotten any security to establish
safety or fails to offer the adroitness to make a class to validate
their variables from end users.
[1]
The PHP filter extension filters data by either validating or sanitizing it. This is
especially useful when the data source contains unknown (or foreign) data, like
user supplied input. For example, this data may come from an HTML form.
[2]
Filter Classes in SPHPlayground offer simple object oriented interface to filtering and validation.
Sphp\Filters namespace contains filters that alter the input
All SPHPlayground filters implement the Filter interface. Build-in filters focus on filtering arrays and scalar values.
Definition a data filter:
All Filter implementations should accept any type of input variable
An implementation should never throw an exception or produce PHP errors or
PHP warnings for any type of input data
Otherwise the implementation of the functionality is totally unrestricted
Because of the above rules these filters are NOT necessarily SAFE
Sanitizing filters
These filters sanitize scalar values or an array of scalars. Similar results can
be achieved by using PHP's filter extension.
An ArrayFilter filters an array of valiables. It
returns filtered values as an array. Individual key -> value pairs are filtered using specified filters like:
FilterAggregate consists of Filter
objects and/or other callables that act as a filter. Individual filters in this aggregate are executed in the order
they are inserted into the aggeragate.
A StringFilter filters input variable as a string.
HtmlIntender indents HTML. It uses Dindent, and thus it will not sanitize or
otherwise manipulate your output beyond indentation.
SQLFormatter indents SQL statement strings. It uses
Doctrine SqlFormatter. This filter
will not sanitize or otherwise manipulate the output beyond indentation.
Special numeric filters
IntegerToRoman creates roman numerals from variables that can
be represented by positive integers.
Ordinalizer creates english ordinal numers. This should only
be used if NumberFormatter is not available.
This site uses cookies
In order to work as intended, this site stores cookies on your device. Accepting
improves our site and provides you with personalized service. Declining results
in one cookie being placed on your device so we remember your choice.