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

如何在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.

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

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

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

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);

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.