By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,256 Members | 1,663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,256 IT Pros & Developers. It's quick & easy.

calling functions with default values for variables

P: n/a
Hi,

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:

checkLogin(2)

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:

checkLogin(,,2,)

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?

J.P.
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
J.P. wrote:
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?


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.
JW

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.