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

小云云
Release: 2023-03-21 12:06:01
Original
2391 people have browsed it

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();//获取方法名
Copy after login
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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!