Category Archives: Filter

FILTER_CALLBACK

It can be used to call a user defined function to filter the value .

Example
======

<?php

function removeSpace($var) {
return str_replace(” “, “”, $var);
}

echo filter_var(“PHP Codez”, FILTER_CALLBACK,array(“options”=>”removeSpace”));
?>

Output
=====

PHPCodez

Share

filter_list()

print all filter as an array

General Format
=============

filter_list()

Example
======

<?php
echo “<pre>”;
print_r(filter_list());
?>

Output
=====

Array
(
[0] => int
[1] => boolean
[2] => float
[3] => validate_regexp
[4] => validate_url
[5] => validate_email
[6] => validate_ip
[7] => string
[8] => stripped
[9] => encoded
[10] => special_chars
[11] => full_special_chars
[12] => unsafe_raw
[13] => email
[14] => url
[15] => number_int
[16] => number_float
[17] => magic_quotes
[18] => callback
)

Share

filter_input_array()

Read more than one input from the outside script and filter all

General Format
=============

filter_input_array(input_type, filter_args)

input_type – A valid input type

*) INPUT_COOKIE
*) INPUT_GET
*) INPUT_ENV
*) INPUT_POST
*) INPUT_SERVER

filter_args – Array filter arguments

Example
=======

<?php
$filters = array( “phone” => FILTER_VALIDATE_INT, “url”=> FILTER_VALIDATE_URL, );
print_r(filter_input_array(INPUT_POST, $filters));
?>

Share