Back to Top

How to use _remap function Codeigniter

Today I am going to write a short post about the _remap() function in CodeIgniter which is used to remap the function with Controller.

What is _remap() function?

In CodeIgniter, You can remap function calls with the use of the function in your controller called _remap() method. The remap() function will call every time that the controller is called even if a different function is used.We can say that remap() function will remap URI requests to specific controller functions.CodeIgniter will call the _remap() function before calling any other function.

This function is very useful to the developers who want to easily remap the function calls or to remap functions instead of extending a routing class of CodeIgniter.

You can alter the default way by including this function in the controller.

SYNTAX:

Where $function is the name of the function you want to intercept and redirect. _remap always gets called first, whatever the URL says.

Let’s see how _remap() function works in CodeIgniter

Generally, First parameter in the URL of Codeigniter defines the name of the controller and the second parameter defines the function to be called.Usually, The second segment of the URI will be passed as a parameter of the _remap() function.The default_controller route identifies that which controller should be loaded if no controller is identified.

You can remap the function calls by using the _remap function in your controller in CodeIgniter. This function will be called everytime controller called even if the different function is used. This function is very helpful for developers who want to remap function call to provide different Uniform Resource Identifier (URI) structure or to remap functions instead of extending the routing class of CodeIgniter.

By the end, I suggest you try, How to Get IP address in CodeIgniter and Image Upload in CodeIgniter.

I hope you have enjoyed this short post. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Share:
Share on Facebook0Share on LinkedIn0Tweet about this on TwitterShare on Google+0Buffer this pageDigg thisShare on Reddit0

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

Basic Github commands

Posted on 2 years ago

Bhumi

WordPress Plugin: Cool Flickr Slideshow

Posted on 5 years ago

Bhumi

Facade implementation in Laravel

Updated 1 month ago

Bhumi

MySQL coalesce() function

Updated 18 years ago

Bhumi

How to use JavaScript Promise API?

Updated 18 years ago

Bhumi

What are Lambdas and Closures in PHP?

Updated 18 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 2 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 3 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 4 years ago

Bhumi