Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to retrieve HTTP $_GET values with CodeIgniter

i'm stuck with using $_GET variables with CodeIgniter, anyone can help me please?

like image 713
Diani Chandra Pertiwi Avatar asked Apr 26 '11 03:04

Diani Chandra Pertiwi


2 Answers

CodeIgniter comes with three helper functions that let you fetch POST, COOKIE or SERVER items. The main advantage of using the provided functions rather than fetching an item directly ($_POST['something']) is that the functions will check to see if the item is set and return false (boolean) if not. This lets you conveniently use data without having to test whether an item exists first. In other words, normally you might do something like this:

if (!isset($_GET['something'])){
    $something = FALSE; 
} else {
    $something = $_GET['something']; 
} 

With CodeIgniter's built in functions you can simply do this:

$something = $this->input->get('something');

Taken from here.

like image 83
tbridge Avatar answered Oct 20 '22 05:10

tbridge


$this->input->get() or $this->input->get_post()

like image 25
ianace Avatar answered Oct 20 '22 05:10

ianace