thinkphp 控制器中 display()步骤实现的原理

WBOY
Release: 2016-06-13 11:07:18
Original
1302 people have browsed it

thinkphp 控制器中 display()方法实现的原理
thinkphp 控制器中 display()方法实现的原理是什么
     display()方法中可以不填写参数 根据调用的方法名称来自动查找模板文件
     请问这是怎么实现的 他是怎么获取调用的方法名称的
      
     请大家共同探讨下  最好能写个能实现这样的功能的代码 或 关键方法和思路
------解决方案--------------------
你搜索一下,读读他的源码不就知道了

<br />        define('MODULE_NAME',self::getModule(C('VAR_MODULE')));<br />        define('ACTION_NAME',self::getAction(C('VAR_ACTION')));<br /><br />/**<br />     +----------------------<br />     * 获得实际的模块名称<br />     +----------------------<br />     * @access private<br />     +----------------------<br />     * @return string<br />     +----------------------<br />     */<br />    static private function getModule($var)<br />    {<br />        $module = (!empty($_GET[$var])? $_GET[$var]:C('DEFAULT_MODULE'));<br />        if(C('URL_CASE_INSENSITIVE')) {<br />            // URL地址不区分大小写<br />            define('P_MODULE_NAME',strtolower($module));<br />            // 智能识别方式 index.php/user_type/index/ 识别到 UserTypeAction 模块<br />            $module = ucfirst(parse_name(P_MODULE_NAME,1));<br />        }<br />        unset($_GET[$var]);<br />        return $module;<br />    }<br /><br />    /**<br />     +----------------------<br />     * 获得实际的操作名称<br />     +----------------------<br />     * @access private<br />     +----------------------<br />     * @return string<br />     +----------------------<br />     */<br />    static private function getAction($var)<br />    {<br />        $action   = !empty($_POST[$var]) ?<br />            $_POST[$var] :<br />            (!empty($_GET[$var])?$_GET[$var]:C('DEFAULT_ACTION'));<br />        unset($_POST[$var],$_GET[$var]);<br />        return C('URL_CASE_INSENSITIVE')?strtolower($action):$action;<br />    }<br /><br />
Copy after login

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!