calling functions with default values for variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J.P.

    calling functions with default values for variables

    Hi,

    I found a function with the following header:

    function checkLogin($use rname = '',$password = '',$groupid =
    10,$goodRedirec t = '',$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.
  • Janwillem Borleffs

    #2
    Re: calling functions with default values for variables

    J.P. wrote:[color=blue]
    > 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?
    >[/color]

    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



    Comment

    Working...