First, CodeIgniter manual related introduction
The second fragment of the URI determines which method in the controller is called. CodeIgniter allows you to use the _remap () method to repeal this rule:
Copy CodeThe code is 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 will eliminate the rule that determines which method is called by the URI fragment, allowing you to redefine the rules that invoke the method (the routing rules for the method).
You can call the _remap () method by Example.com/index.php/blog/To call the specific code if the _remap () parameter is added to the/post parameter.
Ii. Methods of Use 2 cases
But the question is, what is the use of that in the handbook? In fact, there are two of useful:
1, change the URL, hidden methods, such as your application, the original URL method is:
Copy the Code code as follows: Example.com/index.php/blog/say
Now you want to change the display method named:
Copy the Code code as follows: Example.com/index.php/blog/hello
But although the display is Hello, it is actually called the Say method that exists
2, you can also use this function to do a simple function method permission control, such as:
Copy the Code 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 ();
}
else{
$this->show_message ();
}
}
First take the user session in the level $user _type, and then check the method validate_access This user has no permission to call this method ($method), if there is $access_control==true, Otherwise, an error message is displayed.
http://www.bkjia.com/PHPjc/739777.html www.bkjia.com true http://www.bkjia.com/PHPjc/739777.html techarticle I. CodeIgniter manual about the second fragment of the URI determines which method in the controller is called. CodeIgniter allows you to use the _remap () method to repeal this rule: Copy the Code ...