Codeigniter get value from url

How can I get value in controller from following url in codeigniter




class C_service extends CI_Controller {
function __construct()

public function get_radius()

i need to get the vLUE 123 here





source to share

4 answers

In Codeigniter, you can simply do

public function get_radius($lang)
   var_dump($lang); //will output "lang=123"


This way your link can be simplified to http://localhost/directory/c_service/get_radius/123

if you don't want to do something like explode('=', $lang)

to get your value.

You should also consider adding a default value public function get_radius($lang=0)

if the link is opened without a parameter.

Adding more variables is as easy as public function get_radius($lang, $other)




You can use:

$this->input->get('lang', TRUE);


TRUE Enable the XSS filtering you want to enable.

For more information see .



enable url helper in config / autoload.php

$autoload['helper'] = array('url');


or load the url helper in the desired controller or its method



and then use below in your controller



the above line will give you the first parameter, increasing the value you will get the parameters



you get the second, etc.

hope this helps you



I manage it and I check that it works first load url



example: http: // localhost / schoolmanagement / student / studentviewlist / 541

if you use $this->uri->segment(3);

you get (541) id

In the above line, you will get the first parameter, increasing the value, you will get the parameters





All Articles