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;
}
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$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>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). " ) <br>";
}
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>
filter_list() function in PHP?filter_list() retrieve a list of available PHP filters?filter_list() function?filter_list()?filter_list() to retrieve a specific type of filter, such as validation or sanitization filters?filter_list() have any significance?filter_list()?filter_list()?filter_list() to retrieve the names and IDs of the available filters?filter_list()?Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.