Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
url中允许的codeigniter字符_Url_Codeigniter 2 - Fatal编程技术网

url中允许的codeigniter字符

url中允许的codeigniter字符,url,codeigniter-2,Url,Codeigniter 2,使用codeigniter,我在后端传递变量时遇到了一些问题,比如 http://localhost:4949/admin/delete_post/6/?action=delete 生成您提交的URI时使用了不允许的字符。 我知道这个问题可以从config.php$config['allowed_uri_chars']中纠正,但是我如何才能排除对后端的过滤,允许这种结构,并保持前端完整。像这样使用一个符号(&) 它可能会解决你的问题 详细说明如下这种格式在Codeigniter中是不必要的。虽

使用codeigniter,我在后端传递变量时遇到了一些问题,比如

http://localhost:4949/admin/delete_post/6/?action=delete
生成您提交的URI时使用了不允许的字符。


我知道这个问题可以从config.php
$config['allowed_uri_chars']
中纠正,但是我如何才能排除对后端的过滤,允许这种结构,并保持前端完整。

像这样使用一个符号(&)

它可能会解决你的问题


详细说明如下

这种格式在Codeigniter中是不必要的。虽然可以启用查询字符串,但在我看来,使用它们违背了CodeIgniter处理事情的方式。因为您可以通过uri从视图传递变量

http://yourdomain_baseurl/controller/controller_function/var1/var2/var3
我建议采取以下措施:

在url中发送变量,如下所示:

http://yourdomain_baseurl/admin/post_action/id/action
function post_action($id, $action){

    switch ($action) {
        case "delete":
            //do something here with your post with id $id
            break;
        case "update":
            //do something here with your post with id $id
            break;
        case "create":
            //do something here with your post with id $id
            break;
    }

}
在“管理员”控制器中,您可以创建如下内容:

http://yourdomain_baseurl/admin/post_action/id/action
function post_action($id, $action){

    switch ($action) {
        case "delete":
            //do something here with your post with id $id
            break;
        case "update":
            //do something here with your post with id $id
            break;
        case "create":
            //do something here with your post with id $id
            break;
    }

}
或者,如果您希望为每个Post操作创建单独的函数:

http://yourdomain_baseurl/admin/post_delete/id
http://yourdomain_baseurl/admin/post_edit/id
在您的管理控制器中使用以下功能

function post_delete($id){
    //Delete Archive the post with $id here!
}

function post_edit($id){
    //edit the post with $id here!
}
由于大多数用户输入来自表单,因此可以使用$\u POST data获取用户输入。有一个有用的类可以帮助您:

 $this->input->post('some_data');
我建议阅读codeigniter附带的文档并阅读以下内容:

网址

网址