简体   繁体   English

如何在CodeIgniter中使用路由规则获取参数

[英]How to get parameter with routing rules in CodeIgniter

My base_url is "http://localhost/App-Feeder/" 我的base_url是“ http:// localhost / App-Feeder /”

Default controller is "Detail" 默认控制器为“详细信息”

How do i code my routes and controller to get my URL as "http://localhost/App-Feeder/table/place" 我如何编码我的路线和控制器以获取我的URL为“ http:// localhost / App-Feeder / table / place”

Where "place" is a get parameter and should load to another page. 其中“地方”是一个获取参数,应加载到另一个页面。 i tried like this : 我试图这样:

my route.php 我的route.php

$route['table/(:any)'] = "detail/lala/(:any)";

Controller: detail.php 控制器: detail.php

class Detail extends CI_Controller {

    public function lala($place)
    {
        echo "choose=".$place;
    }
}

but it will display : 但会显示:

choose=(:any)

it should be display : 它应该显示:

choose=place

Can anyone help me ? 谁能帮我 ?

replace 更换

 $route['table/(:any)'] = "detail/lala/(:any)";

with

 $route['table/(:any)'] = "detail/lala/$1";

为了更好地了解codeignitor,请点击此处,并尝试解决您的问题

$route['product/(:any)'] = "catalog/product_lookup_by_id/$1";

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

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