Welcome Guest, Not a member yet? Register   Sign In
passing 1 (or more) param's to a controller function?
#1

[eluser]PeteSig[/eluser]
From the tutorials / examples / user guide, if you're only going to pass a single param you do:

Code:
// set default NULL value to $in so we don't crash & burn
// if func called without a param!
// Not strictly required, but I read somewhere in the forum that its desirable!
function doSomething($in = NULL)
{
    if(NULL != $in)
    {
        // do something....
    }
    else
    {
        //nothing passed in so....
    }
}

But if I were to pass more than 1 or more params would I do:
Code:
function doSomething($in = NULL)
{
    if(NULL != $in)
    {
        $params = $this->uri->segment_array();
        foreach($params as $p)
        {
            // do something with $p ....
        }        
    }
    else
    {
        //nothing passed in so ....
    }
}

Is this correct / prefered method?

Cheers

Pete


Messages In This Thread
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 10:01 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 10:09 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 10:30 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 10:53 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 11:10 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 11:11 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 11:18 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 11:24 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 11:31 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 11:48 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 12:22 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 06:36 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-03-2010, 03:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB