【问题标题】:Can't get the URI from a URL that contains parameters无法从包含参数的 URL 获取 URI
【发布时间】:2014-04-18 11:51:30
【问题描述】:

所以,当我尝试获取 thsi URL:http://example.com/first-uri/6 的 URI 字符串(echo $this->uri->segment(2);) 时,我得到“6”,所以那里没有问题,但同样的请求对以下 URL(具有参数)进行处理:http://example.com/first-uri?parameter1=x&parameter2=y/6 确实返回任何内容。

有什么想法吗?

谢谢

【问题讨论】:

  • 使用 $this->input->get('parameter1') .
  • 您是否将 $config['enable_query_strings'] 更改为 true
  • 是的!这就是问题所在。谢谢

标签: php codeigniter uri


【解决方案1】:

使用

//print_r($_REQUEST); 

echo $_REQUEST['parameter1']; //$this->input->get('parameter1')
echo $_REQUEST['parameter2'];//$this->input->get('parameter2')

【讨论】:

  • ..不,我正在尝试获取第二个 URI,在本例中为 6,而不是参数。它仅适用于没有参数的 URL。
  • 一次打印数组 //print_r($_REQUEST);
【解决方案2】:

首先你的表单方法应该是 POST 类型 <form method='post'> 。或者你必须使用 $this->input->get('parameter');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-06
    • 2017-10-06
    • 2017-10-15
    • 2021-05-18
    • 2014-06-13
    • 1970-01-01
    • 2011-04-01
    • 2014-06-13
    相关资源
    最近更新 更多