如何使用GET表单与CodeIgniter? [英] How can I use GET forms with CodeIgniter?

查看:124
本文介绍了如何使用GET表单与CodeIgniter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解CI主要是基于网址段,但我想要一个查询字符串:blahblah.com/search.html?q=keyword



当我尝试$ this-> input-> get(q),它返回空。是否有路由或需要配置的东西?

解决方案

在CodeIgniter中获取查询字符串的最好方法是使用Google 。这个问题在论坛,这里和Twitter上至少每天10次被询问(和回答)。



有几种方法,但最近我是一个粉丝的以下方法:



http://www.dijexi.com/2009/08/how-to-mix-segment-and-query-string-in-codeigniter/



我更喜欢这个比其他的,因为它将没有应用程序范围的效果像一些其他的方法,它不会需要任何疯狂的黑客来让它工作。 p>

如果你想在整个应用程序中支持$ _GET,只需将parse_str放入MY_Controller或者pre_controller。


I understand that CI is mostly URL segment based, but I want to have a query string: blahblah.com/search.html?q=keyword

When I try $this->input->get( "q" ), it returns empty. Is there a route or something I need to configure?

解决方案

The best way to get query strings working in CodeIgniter is to use Google. This question is asked (and answered) on the forums, here and on twitter at least 10 times a day.

There are a few methods, but recently I am a fan of the following method:

http://www.dijexi.com/2009/08/how-to-mix-segment-and-query-string-in-codeigniter/

I prefer this over others as it will have no application-wide effects like some other approaches and it won't require any crazy hacking to get it working.

If you want this $_GET support throughout the entire app, just put the parse_str into MY_Controller or a pre_controller hook.

这篇关于如何使用GET表单与CodeIgniter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆