duanaoyuan7202
2016-08-25 06:15
浏览 34
已采纳

如何在codeigniter 3中的url中传递和获取变量

How can i send variables in the url using codeigniter. I already read some forums but i didn't find the correct syntax for it.

Here is the format i want to have in the url

http://localhost/acc/index.php/Jev/entryAccount/2016-08-0042

your help is very much appreciated. Thank you.

图片转代码服务由CSDN问答提供 功能建议

如何使用codeigniter在url中发送变量。 我已经阅读了一些论坛,但我找不到正确的语法。

以下是我想在网址中提供的格式

http://localhost/acc/index.php/Jev/entryAccount/2016-08-0042 < 非常感谢你的帮助。 谢谢。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dqrm8199 2016-08-25 06:26
    已采纳

    Try this:

    first you put your variables in query string like this:

    redirect('mycontroler/senddata/'.$name.'/'.$email);
    

    In controler receive parameters in this way:

    public function senddata($name,$email)
    {
       // do you stuff here
    }
    

    Or to receive parameter you can use:

    $this->uri->segment(number);
    
    已采纳该答案
    打赏 评论
  • dongleibeng5602 2016-08-25 06:25

    Please go through the documentation carefully first. In Codeigniter or any other MVC the url generally follows this rule example.com/class/function/ID. In your case the data 2016-08-0042 will automatically be available as a parameter to the entryAccount method in the Jev class.

    打赏 评论

相关推荐 更多相似问题