PHP 5 Filter Functions - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
PHP Filter Functions

PHP 5 Filter Functions

PHP 5 Filter Functions

Since PHP 5.2.0, the filter functions are enabled by default. You can use them directly in your code without any further installation.
FunctionDescription
filter_has_var()Checks if variable of specified type exists
filter_id()Returns the ID number of a specified filter
filter_input()Gets a specific external variable by name and optionally filters it
filter_input_array()Gets multiple external variables and optionally filters them
filter_list()Returns an array of all supported filters
filter_var_array()Gets multiple variables and optionally filters them
filter_var()Filters a variable with a specified filter

PHP Sanitize Filters

The sanitize filters are used to sanitize or clean the user inputs.
IDDescription
FILTER_SANITIZE_EMAILRemove all characters except letters, digits and !#$%&'*+-/=?^_`{|}~@.[]
FILTER_SANITIZE_ENCODEDURL-encode string, optionally strip or encode special characters.
FILTER_SANITIZE_MAGIC_QUOTESApply addslashes().
FILTER_SANITIZE_NUMBER_FLOATRemove all characters except digits, +- and optionally .,eE
FILTER_SANITIZE_NUMBER_INTRemove all characters except digits, plus (+) and minus (-) sign.
FILTER_SANITIZE_SPECIAL_CHARSHTML-escape '"<>& and characters with ASCII value less than 32, optionally strip or encode other special characters.
FILTER_SANITIZE_STRINGStrip tags, optionally strip or encode special characters.
FILTER_SANITIZE_STRIPPEDAlias of "string" filter.
FILTER_SANITIZE_URLRemove all characters except letters, digits and $-_.+!*'(),{}|\\^~[]`<>#%";/?:@&=
FILTER_UNSAFE_RAWDo nothing, optionally strip or encode special characters.

Validate Filters

The sanitize filters are used to validate the user inputs.
IDDescription
FILTER_VALIDATE_BOOLEANReturns TRUE for "1", "true", "on" and "yes". Returns FALSE otherwise.
FILTER_VALIDATE_EMAILValidates value as e-mail.
FILTER_VALIDATE_FLOATValidates value as float.
FILTER_VALIDATE_INTValidates value as integer optionally from the specified range.
FILTER_VALIDATE_IPValidates value as IP address, optionally only IPv4 or IPv6 or not from private or reserved ranges.
FILTER_VALIDATE_REGEXPValidates value against regexp, a Perl-compatible regular expression.
FILTER_VALIDATE_URLValidates value as URL, optionally with required components.

About Mariano

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.