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.

Comments (1)

  1. www.mahaset.com says:

    Thanks for sharing such a nice thought, article is nice, thats why i
    have read it completely

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

Learn about InnoDB MySQL Storage Engine

Posted on 12 years ago

Bhumi

How to use PHP Method Chaining?

Posted on 9 years ago

Bhumi

How To Turn On Output Buffering

Posted on 12 years ago

Bhumi