简体   繁体   中英

How to pass and get variables in the url in codeigniter 3

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM