PHP function missing argument error

My validate function looks like that

function validate($data, $data2 = 0, $type)

Function call example

if ($result = validate($lname, 'name') !== true)
        response(0, $result, 'lname');

As you see, my validate function has 3 input vars. I'm not using second var - $data2 often, that's why set it to 0 by default. But when I'm calling this function as given example (as far as I know it means $data=$lname, $data2=0, $type='name') getting error message

Missing argument 3 ($type) for validate() 

How can I fix that?


Missing argument 3 ($type) for validate()

Always list optional arguments as the last arguments. Since PHP doesn't have named parameters nor "overloading ala Java", that's the only way:

function validate($data, $type, $data2 = 0) {

Need Your Help

Disable notifications from other apps

java android

i want to disable notifications coming from other apps like Facebook and other apps.

Convert a string timezone to NSTimeZone

objective-c nsdate

I have a time zone formatted like this in an incoming string which I have no control over (it comes in a dictionary from server)