i
PHP Variables
PHP Data Types
PHP Echo & Print
PHP Strings
PHP Numbers
PHP Constants
PHP Operators
PHP if...else...elseif Statements
Switch Statement
PHP Loops
PHP Arrays
Superglobals
PHP Coding Standards
PHP Form Handling
PHP Form Validation
PHP URLs Validation
PHP Form Required Validation
Complete Form Example
PHP File Functions Open/Read
PHP File Create/Write
PHP File Upload
PHP Cookies Handling
PHP Session Handling
PHP filter_var() Function
PHP Validation Filters
PHP Sanitization Filters
Using Filters
Filters Advanced
JSON
PHP Date and Time
MySQL Database
MySQL Connect
MySQL Commands-Creating a Table
MySQL Commands-Inserting The data
MySQL Commands-Prepared Statement
MySQL Commands-Selecting The Data
MySQL Commands-Where and Order By
MySQL Commands-Deleting And Updating The Data
PHP-OOP Introduction
PHP-Classes/Objects
PHP-Constructor/Destructor
PHP-Access Modifiers
PHP-Inheritance
PHP-Inheritance and Protected Access Modifier
PHP-Overriding Inherited Methods
PHP-Final keyword
PHP-Abstract Classes
PHP-Constants
PHP-Traits
PHP-Static Methods and Properties
Introduction to Functions
Defining A function
Returning Values From A Function
Dynamic Function Calls
Variable Scope
Understanding Arguments Or Parameters
Testing For A Function Existence
Returning Multiple Values From A Function
Making practical Use By Building Code Libraries For Code Re-usability
Using Include() And Require()
PHP filters are used to validate and sanitize any external input and is very useful when the data source contains any unknown data or user input. For example, data from an HTML form, cookies, web service data, sql statements results, service variables etc.
There are two types of filters in PHP
1. Validation – Validation is used to check or validate if the data meets certain requirements such as FILTER_VALIDATE_EMAIL will check for a valid email address, but it will not change the data or user input.
2. Sanitization – Sanitization will sanitize the data and it can change the data by removing any undesired characters. For example, FILTER_SANITIZE_EMAIL will remove the characters that are not correct for an email address or an email should not contain.
PHP filter extension has many functions that are required to check user input and it makes data validation easier. You can use filter_list() function to list all the filter names or id that filter extension offers.
PHP Filter_var() Function
filter_var() function is used to sanitize and validate the data and it filters a single variable with a filter specified in the function.
Syntax : filter_var(variable, filter, options);
where variable is the value to filter, filter is the ID of filter to apply, and options specifies one or more flags to be used.
For example: filter_var(‘contact@yourphp.com’, FILTER_VALIDATE_EMAIL);
filter_var($email, FILTER_CALLBACK, array(‘options’ => ‘strtoupper’));
Don't miss out!