Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.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
Php 从Codeigniter URL获取参数数据_Php_Codeigniter - Fatal编程技术网

Php 从Codeigniter URL获取参数数据

Php 从Codeigniter URL获取参数数据,php,codeigniter,Php,Codeigniter,我正在从事一个CI项目,需要将数据作为url参数发送到控制器。我习惯于这样做 <a href="site/controller/function?id=1"> 然后我就可以使用$\u GET获取参数 然而,我被告知使用这种方法 <a href="site/controller/function/1"> 我这样做了,当我点击链接时,它显示在url中,但我不知道如何获取实际参数 有什么建议吗?我想出来了,我用了下面的方法 $id=$this->uri->

我正在从事一个CI项目,需要将数据作为url参数发送到控制器。我习惯于这样做

<a href="site/controller/function?id=1">

然后我就可以使用$\u GET获取参数

然而,我被告知使用这种方法

<a href="site/controller/function/1">

我这样做了,当我点击链接时,它显示在url中,但我不知道如何获取实际参数


有什么建议吗?

我想出来了,我用了下面的方法

$id=$this->uri->segment(3);

这就得到了我传递的id号。

你最好在你的codeIgniter函数中使用下面的代码。即使你的代码也很好

function funcName ($param1)
{
 echo $param1;
}

这是一个路由参数。您可以设计一种临时的方式来获取这些信息,但我建议使用一个为您提供路由的框架。不过,使用GET变量就足够了。