I have gone through with the JInput Documentation.
We can access the JInput object like this:
JFactory::getApplication()->input;
If we are retrieving more values, it would be useful to store the JInput object in a variable so we don’t need to call JFactory::getApplication()
every time we are doing that:
$jinput = JFactory::getApplication()->input;
To retrieve a value from JInput we need to use its get method:
$data = $jinput->get('varname', 'default_value', 'filter');
As you can see, it has 3 parameters:
- the variable name
- the default value (defaults to null)
- the filter name (defaults to cmd)
And here comes my question regarding the 3rd parameter.
How can I make my own filter for Jinput
?
For example if I have to validate phone numbers or IP address then how can I make my own filter for that?