PHP Filter_Callback Filter

What is FILTER_CALLBACK Filter in PHP?


PHP FILTER_CALLBACK is used to call a user defined function or any PHP function to filter and validate the value.
Name: "callback"
ID-number: 1024

Example :

$string="We welcome you to";
echo filter_var($string, FILTER_CALLBACK, array("options"=>"ucwords"));

Result :

We Welcome You To

In the above example, the first character of each word in the given sentence is capitalized.

Here the user defined functions is $string which is validated and the output is given.

PHP Topics

Ask Questions

Ask Question