Passing URI Segments to CI Controller Methods

Most of this information is copied from the UG.

Passing Parameters to your Controller’s Method Using the URI in your Request could have been the title of this post.

If your URI contains more than two segments they will be passed to your function (controller method) as parameters.

For example, lets say you have a URI like this:

Your function will be passed URI segments 3 and 4 ("sandals" and "123"):

class Products extends CI_Controller {

    public function shoes($sandals, $id)
        echo $sandals;
        echo $id;

If you are using the URI Routing feature, the segments passed to your function will be the re-routed ones.


About samehramzylabib

See About on
This entry was posted in CodeIgniter. Bookmark the permalink.


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s