In the CodeIgniter framework

Source: Internet
Author: User
Tags codeigniter

  This article mainly introduces the use of _remap () in CodeIgniter 2 cases, the need for friends can refer to the following

Introduction to CodeIgniter Handbook The second fragment of the URI determines which method in the controller will be invoked. CodeIgniter allows you to use the _remap () method to repeal this rule:   code as follows: Public function _remap ()   {     //Some code here. ..  } NOTE: If your controller contains a method named _remap (), it will always be ignored regardless of what your URI contains. This method abolishes the rule that determines which method is invoked by the URI fragment, allowing you to redefine the rule that invokes the method (the routing rule for the method).   can call the _remap () method via Example.com/index.php/blog/ , if _remap () has parameters, then call the specific code in/after the parameter. Ii. 2 cases of usage but the question is, what's the use of that in the manual? In fact, the use of two:    1, change the URL, hiding methods, such as your application, the original URL method is:       Code as follows: Example.com/index.php/blog/say Now want to change the display of the method named:   Copy code is as follows: Example.com/index.php/blog/hello But the display is Hello, but it is actually called the existence of the Say method   2, You can also use this function to do simple function method permission control, such as:   Code as follows: Public function _remap ($method, $params = Array ())   {      $user _type = $_session[' User_type '];       $access _control = $this->validate_access ($user _type, $method);       if ($access _control) {          $this-> $method ();      }     &nbsp else{          $this->show_message ()      }   First remove the level in the user session $user _type, and then check the method  validate_access This user has permission to call this method ($method), if any $access_control==true, otherwise display error message.
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.