how to retrieve HTTP $_GET values with CodeIgniter
i'm stuck with using $_GET variables with CodeIgnit开发者_运维知识库er, anyone can help me please?
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.
$this->input->get()
or $this->input->get_post()
use Input::get():
echo $this->input->get('your_field');
There's no reason that you would be able to use $this->input->get()
and not $_GET
.
You may be running an older version (less than 2.0.1) that does not have real $_GET "support". Old versions intentionally unset the $_GET array, assuming because it made things "difficult" for the developers. There is a query strings setting in version 1.7.2 that is very confusing and does not do what you'd expect. Newer versions support $_GET as expected.
Please see here for more information if this is the case:
CodeIgniter Enabling Query Strings
I think you must enable 'enable_query_strings = true' first
精彩评论