简体   繁体   English

在 codeigniter 中处理获取 url

[英]handling get urls in codeigniter

I am trying to create a message that shows up when login.php?e=1 on the login page: /login/ .我正在尝试创建一条消息,当login.php?e=1在登录页面上时显示: /login/ The issue I am coming to have is that in codeigniter when I do /login/e/1/ codeigniter seems to think e is a function and thus, since it doesnt exist, outputs a 404 .我即将遇到的问题是,当我执行/login/e/1/ codeigniter 时,在 codeigniter 中似乎认为e是一个函数,因此,由于它不存在,因此输出404 I am trying, in the index function to grab the segments like a get request, however this does not work.我正在尝试在索引函数中像获取请求一样抓取段,但这不起作用。 How can one do typical get requests that would be trivial outside of codeigniter, in codeigniter while staying true to the uri that codeigniter uses?如何在 codeigniter 之外执行在 codeigniter 中微不足道的典型 get 请求,同时忠于 codeigniter 使用的 uri?

    // Are they attempting to access a secure page?
    if ($this->uri->segment(1) == 'e' && $this->uri->segment(2) == '1'):
        if ($this->generic->getOption('block-msg-out-enable')) {
            $this->msg = $this->generic->getOption('block-msg-out');
        }
    endif;

there is nothing to show just hit this link .没有什么可显示的,只需点击此链接即可

If you are lazy then watch it here.如果你很懒,那么看这里。

_remap function overrides index() (or any other declared function in a controller), in a way _remap函数以某种方式覆盖index() (或控制器中的任何其他声明函数)

function _remap($method, $params) {

    if (method_exists($this, $method)) {

        return call_user_func_array(array($this, $method), $params);

    } else {

        array_unshift($params, $method);
        return call_user_func_array(array($this, "index"), $params);

    }

}

//after 1st comment take a look here //在第一条评论之后看这里

function _remap($method, $params) { //this is "kind" of your new index(); but it takes parameters

    if ($method == 'e') {

        echo $params[0];

    } else {

        show_404();

    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM