如何在codeigniter中的baseurl之后传递参数? [英] How to pass parameter after baseurl in codeigniter?

查看:59
本文介绍了如何在codeigniter中的baseurl之后传递参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本网址: http://localhost/f1/

,并且我在URL中传递参数,例如: http://localhost/f1/user1

and I am passing parameter in URL like: http://localhost/f1/user1

我正在尝试打印

function index(){
    echo $this->uri->segment(2);
}

我想在控制器中打印 User1 .如何实现呢?

I want to print User1 in the controller. How to achieve this?

推荐答案

配置您的溃败并添加以下内容:

Config your rout and add this:

$route['Controller_Name/(:any)'] = 'Controller_Name/index/$1';

在这里,您随身携带控制器

Here you go with your controller

class Controller_Name extends CI_Controller {
  function index($prm){
    echo $prm;
  }
}

玩得开心..您可以拥有多少个您想要的尿....

Have fun.... you can have how many uri you want....

这篇关于如何在codeigniter中的baseurl之后传递参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆