将以下库添加到您的应用程序库。它覆盖清除$ _GET数组的默认输入库的行为。它允许URI段和查询字符串混合使用。
应用程序/库/MY_Input.php
class MY_Input extends CI_Input { function _sanitize_globals() { $this->allow_get_array = TRUE; parent::_sanitize_globals(); }}修改某些配置设置也很有必要。uri_protocol设置需要更改为PATH_INFO,并且将’?’ 需要将字符添加到URI中允许的字符列表中。
application / config / config.php
$config['uri_protocol'] = "PATH_INFO";$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-?';
然后可以访问通过查询字符串传递的值。
$this->input->get('x');


