简体   繁体   中英

how to retrieve HTTP $_GET values with CodeIgniter

我坚持使用CodeIgniter使用$ _GET变量,有人可以帮我吗?

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()$this->input->get_post()

使用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

我认为你必须首先启用'enable_query_strings = true'

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