Welcome Guest, Not a member yet? Register   Sign In
Default parameters for controller functions
#1

[eluser]chaotiq[/eluser]
Can I give a default parameter for controller functions and then override with a uri?

Consider the following code.
Code:
Class My_controller extends Controller{

    function my_function($var = 0)
    {
        if ($var == 0)
        {
            //do stuff
        }
        else
        {
            //do other stuff
        }
    }
}

If I call the function without giving it a parameter the first part of the if statement works as intended. However, if I try to go to:

http://mysite.com/index.php/my_controlle...nction/213

I would expect the 213 to override the default of 0 and the else should run. When I try this the first part of the if statement still runs.

Am I thinking about this wrong?

[Edit: formatting]


Messages In This Thread
Default parameters for controller functions - by El Forum - 01-19-2010, 04:27 PM
Default parameters for controller functions - by El Forum - 01-19-2010, 04:31 PM
Default parameters for controller functions - by El Forum - 01-19-2010, 04:40 PM
Default parameters for controller functions - by El Forum - 01-19-2010, 04:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB