How can i skip first argument without giving any value in function call,so that first argument can take default value NULL?
function test($a = NULL, $b = tru
You can change the position of the arguments, or you can pass the arguments as an array, for exmaple:
test($options);
YOu have to use the format defined my the PHP function standards
test("",false);
The requirement you have works with jquery libraries...for arguments passing in its functions. But NOT in PHP
You cannot just skip an argument in PHP.
You may wish to consider the Perl trick and use an associated array. Use array_merge
to merge the parameters with the defaults.
e.g.
function Test($parameters = null)
{
$defaults = array('color' => 'red', 'otherparm' => 5);
if ($parameters == null)
{
$parameters = $defaults;
}
else
{
$parameters = array_merge($defaults, $parameters);
}
}
Then call the function like this
Test(array('otherparm' => 7));
Redifine your function as
function test($b = true,$a = NULL){
//logic here
}
And you can call it like test(5); avoiding second parameter.