Philter
class Philter
A PHP fluent input sanitiser.
Philter will sanitise any untrusted scalar value by chaining methods together, finally calling toString() toInt() or toFloat() to return the filtered input.
Methods
The constructor requires the untrusted input.
Return the variable cast as a Boolean
Return the variable cast as a Float
Return the variable cast as an Integer
Return the variable cast as a String
Checks that the variable contains the string in $match
Filter to check if the value is in the provided array of values
Check the input is greater than the value of max, sets var to null if less than $Min
Check the input is less than the value of max, sets var to null if greater than $max
Removes any non numeric characters, allows typical currency markup + or - commas and decimals
Removes the majority of HTML tags leaving only a basic set without attributes
Removes all javascript
Removes the majority of HTML tags leaving only a basic set without attributes
Removes any unprintable characters, this filter is processed by default
Details
        at line 34
                            
    __construct(scalar $var, bool $raw = false)
        
    
    The constructor requires the untrusted input.
Optionally a boolean to skip trimming and removing unprintable characters
        at line 76
                            bool|null
    toBool()
        
    
    Return the variable cast as a Boolean
        at line 86
                            float|null
    toFloat(int|null $decimals = null)
        
    
    Return the variable cast as a Float
        at line 99
                            int|null
    toInt()
        
    
    Return the variable cast as an Integer
        at line 108
                            string|null
    toString()
        
    
    Return the variable cast as a String
        at line 123
                            Philter
    allow(string $allowed)
        
    
    Removes any characters that are not in the allow list
        at line 141
                            Philter
    alpha(string|null $allowed = null)
        
    
    Removes any non alphabetical characters
        at line 151
                            Philter
    alphanum(string|null $allowed = null)
        
    
    Removes any non alpha-numeric characters
        at line 171
                            Philter
    ascii()
        
    
    Removes any non-ascii characters, transliterating as necessary
        at line 216
                            Philter
    between(int $min, int $max)
        
    
    Filters the variable, ensuring it is between $min and $max
        at line 234
                            Philter
    contains(string $match, bool $match_case = false)
        
    
    Checks that the variable contains the string in $match
        at line 255
                            Philter
    cut(int|null $length)
        
    
    Shortens the length to $len characters
        at line 276
                            Philter
    default(mixed $default)
        
    
    Sets a default value to be returned if the variable is null
        at line 290
                            Philter
    digits(string|null $allowed = null)
        
    
    Removes any non numeric characters
        at line 301
                            Philter
    in(array $values, string $match_case = false)
        
    
    Filter to check if the value is in the provided array of values
        at line 321
                            Philter
    min(int $min)
        
    
    Check the input is greater than the value of max, sets var to null if less than $Min
        at line 338
                            Philter
    max(int $max)
        
    
    Check the input is less than the value of max, sets var to null if greater than $max
        at line 355
                            Philter
    numeric(string|null $allowed = null)
        
    
    Removes any non numeric characters, allows typical currency markup + or - commas and decimals
        at line 365
                            Philter
    trim(string|null $char = null)
        
    
    Trims the leading and trailing characters from the variable
        at line 383
                            Philter
    ltrim(string|null $char = null)
        
    
    Trims the leftmost character matching $char
        at line 401
                            Philter
    rtrim(string|null $char = null)
        
    
    Trims the rightmost character matching $char
        at line 419
                            Philter
    utf8(bool $ignore = false)
        
    
    Convert the string to UTF-8 transliterating if possible
        at line 445
                            Philter
    stripAttributes(string|null $allowed_tags = null)
        
    
    Removes the majority of HTML tags leaving only a basic set without attributes
        at line 470
                            Philter
    stripHtml()
        
    
    Removes all HTML and javascript
        at line 482
                            Philter
    stripJavascript()
        
    
    Removes all javascript
        at line 500
                            Philter
    stripTags(string|null $allowed_tags = null)
        
    
    Removes the majority of HTML tags leaving only a basic set without attributes
        at line 520
                            Philter
    stripUnprintable()
        
    
    Removes any unprintable characters, this filter is processed by default