Home  >  Article  >  Backend Development  >  How does the CI framework obtain the controller name and method name?

How does the CI framework obtain the controller name and method name?

小云云
小云云Original
2018-03-14 13:49:522349browse

This article mainly shares with you how the CI framework obtains the controller name and method name. There are three methods in total. I hope it can help you.

The first method:

Even if there are __CLASS__, __FUNCTION__ magic variables, but in the parent class controller, or In the model, only the class name and method name of the current class can be obtained.

Second method:

##$this- >uri->segment(3, 0 );

This is obtained through the URL. In case the url route is customized, this method is not very elegant.

##The third method: (Perfect)

  $con = $this->router->fetch_class();//获取控制器名
  $func = $this->router->fetch_method();//获取方法名
This is a method that comes with the framework. It is not introduced in the official documentation. I dug deeper into the framework and learned that it is valid in 2.x.....

Related Recommended:


Yii2 Get module name, controller name, method name

The above is the detailed content of How does the CI framework obtain the controller name and method name?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn