2. TOPICS TO BE COVERED
• Metacharacters
• Php Function filter_var()
muhammadabaloch
3. METACHARACTERS
• Metacharacters are characters with a special meaning:
Metacharacter Description
w Finds word character i.e. (alphabets and
number)
W Finds non-word character i.e. (Special
Characters)
d Finds digit i.e. (Numbers)
D Finds non-digit character i.e. (alphabets
and Special Characters)
muhammadabaloch
4. METACHARACTERS
$string = "ali123"; // Characters+ number
$patt = "/w/";
$string = "$ _-+"; // Special Characters
$patt = "/W/";
$string = "$*&"; // number
$patt = "/d/"; // return false
$string = “1234"; //alphabets and Special Characters
$patt = "/D/";
muhammadabaloch
5. PHP FUNCTION filter_var()
• The filter_var() function filters a variable with the specified filter.
• Returns the filtered data on success or FALSE on failure.
Syntax
filter_var( variable , filter , options )
Parameter Description
variable Required. Specifies the variable to filter
filter Optional. Specifies the ID of the filter to
use. Default is FILTER_SANITIZE_STRING.
options Optional. Specifies an associative array of
flags/options or a single flag/option. Check
each filter for possible options and flags
muhammadabaloch
6. PHP FUNCTION filter_var()
• Number (Integer) Validation
• Number (Integer) validation with range
• Validation String with Regular Expression
• Email Validation
muhammadabaloch