Why does the get parameter not get "C"?

Source: Internet
Author: User
Keywords php thinkphp

When the URL is accompanied by the parameter "C", how can $_request not get the value?

But if you change the parameter to another name, such as the uppercase "C", you can get the value.

Excuse me, what's going on?

Reply content:

When the URL is accompanied by the parameter "C", how can $_request not get the value?

But if you change the parameter to another name, such as the uppercase "C", you can get the value.

Excuse me, what's going on?

It's used, right thinkPHP ? thinkPHPby default, the name of the GET act in the parameter is fetched c controller and dispatched as such. You can config change the value in the file VAR_CONTROLLER to select other parameters as the controller name, so that the C parameter will not be prevented from passing.

In the framework of thinkphp, the request Distribution section needs to parse the M c a parameter, and after parsing it removes the corresponding parameter from the $_get array
path\to\thinkphp\library\think\think.class.php

    /**     * 应用程序初始化     * @access public     * @return void     */    static public function start() {        ...        // 运行应用      App::run();    }

path\to\thinkphp\library\think\app.class.php

    /**     * 运行应用实例 入口文件使用的快捷方法     * @access public     * @return void     */    static public function run() {        ...        App::init();        ...    }
    /**     * 应用程序初始化     * @access public     * @return void     */    static public function init() {        ...        // URL调度        Dispatcher::dispatch();        ...

path\to\thinkphp\library\think\dispatcher.class.php

    /**     * URL映射到控制器     * @access public     * @return void     */    static public function dispatch() {        ...        // 获取模块名称        define('MODULE_NAME', defined('BIND_MODULE')? BIND_MODULE : self::getModule($varModule));        ...        // 获取控制器的命名空间(路径)        define('CONTROLLER_PATH',   self::getSpace($varAddon,$urlCase));        // 获取控制器和操作名        define('CONTROLLER_NAME',   defined('BIND_CONTROLLER')? BIND_CONTROLLER : self::getController($varController,$urlCase));        define('ACTION_NAME',       defined('BIND_ACTION')? BIND_ACTION : self::getAction($varAction,$urlCase));        ...
    /**     * 获得实际的控制器名称     */    static private function getController($var,$urlCase) {        ...        $controller = (!empty($_GET[$var])? $_GET[$var]:C('DEFAULT_CONTROLLER'));        unset($_GET[$var]);        ...    }

The code that gets the module and the action method is similar.

In fact, should not be directly from the $_get to fetch data, because if you use PathInfo URL mode or rewrite URL pattern when these parameters are not $_get

What's your post?

  • 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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.