filter_list & filter_id

PHP Filters: validation and sanitization reference

Use validation filters when you need to decide whether data matches a required format. Sanitization changes data and is not a substitute for output escaping or prepared SQL statements.

$filters = filter_list();
foreach ($filters as $name) {
    echo $name . ' => ' . filter_id($name) . PHP_EOL;
}
We can display list of available filters by using filter_list function. This function returns an array with list of available filters as elements. Here is the example.
print_r(filter_list());
The output is here
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 )
Now we will modify it by displaying in a formatted output. We used standard array display techniques to display the elements of the array
Here is the code to display output
$ar=filter_list();
	foreach ($ar as $key => $val) {
echo "$key => $val 
"
;
The output is here ( Note that the serial number is the key number of the array filter_list not the filter ID number )
$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>$key => $val <br>

filter_id

WE can get the filter id of the particular filter in PHP by using filter_id function. We will input the name of the filter and get the associated id of it. The list containing name of filter is available at filter_list page. Here is the syntax.
Int filter_id(filter name)
Here is one example echo filter_id('validate_url'); The output of above line is here
273
We can also display the associated id of all the filters in a single list. Here is the sample code.
$ar=filter_list();<br>
foreach ($ar as $key => $val) {
echo "$key -> $val : ( ".filter_id($val). " ) &lt;br&gt;";
} 
The output is here
$key -> $val : ( 257 ) <br>$key -> $val : ( 258 ) <br>$key -> $val : ( 259 ) <br>$key -> $val : ( 272 ) <br>$key -> $val : ( 277 ) <br>$key -> $val : ( 273 ) <br>$key -> $val : ( 274 ) <br>$key -> $val : ( 275 ) <br>$key -> $val : ( 276 ) <br>$key -> $val : ( 513 ) <br>$key -> $val : ( 513 ) <br>$key -> $val : ( 514 ) <br>$key -> $val : ( 515 ) <br>$key -> $val : ( 522 ) <br>$key -> $val : ( 516 ) <br>$key -> $val : ( 517 ) <br>$key -> $val : ( 518 ) <br>$key -> $val : ( 519 ) <br>$key -> $val : ( 520 ) <br>$key -> $val : ( 523 ) <br>$key -> $val : ( 1024 ) <br>

Questions




Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer