calling functions with default values for variables

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I found a function with the following header:

function checkLogin($username = '',$password = '',$groupid =
10,$goodRedirect = '',$badRedirect = '')

Now the writer of this function is calling it by the following statement:


The author of this function wants that $groupid is set to 2. This
doesn't work. But how can I call this function so it does work?

I tried:


But as I expected that didn't work. So how do I call functions with
default values and I only want to change the middle variable?


Re: calling functions with default values for variables

J.P. wrote:
Quoted text here. Click to load it

You will have to provide the arguments preceding the one you want to set.

So, if you want to set the groupid, you should call the function as follows:

checkLogin("", "", 2);

Here, the first and second arguments are set with their default values.


Site Timeline