• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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, 11:01 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 11:09 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 11:30 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 11:53 AM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 12:10 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 12:11 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 12:18 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 12:24 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 12:31 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 12:48 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 01:22 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-02-2010, 07:36 PM
passing 1 (or more) param's to a controller function? - by El Forum - 11-03-2010, 04:54 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.