使用 CodeIgniter 获取 URL 中的参数 [英] GET parameters in the URL with CodeIgniter

查看:24
本文介绍了使用 CodeIgniter 获取 URL 中的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 codeIgniter 默认关闭 GET 参数.

I know that codeIgniter turns off GET parameters by default.

但是通过在 POST 中完成所有操作,如果您在提交表单后按回,您不会对重新发送数据请求感到恼火吗?

But by having everything done in POST, don't you get annoyed by the re-send data requests if ever you press back after a form submission?

这让我很恼火,但我不确定是否纯粹是因为这个原因才允许 GET.

It annoys me, but I'm not sure if I want to allow GET purely for this reason.

允许GET参数也有这么大的安全问题吗?

Is it such a big security issue to allow GET parameters too?

推荐答案

当我第一次开始使用 CodeIgniter 时,不使用 GET 也让我很失望.但后来我意识到您可以通过使用内置的 URI Class.这太棒了,它使您的网址看起来更好.

When I first started working with CodeIgniter, not using GET really threw me off as well. But then I realized that you can simulate GET parameters by manipulating the URI using the built-in URI Class. It's fantastic and it makes your URLs look better.

或者如果你真的需要 GET 工作,你可以把它放到你的控制器中:

Or if you really need GETs working you can put this into your controller:

parse_str($_SERVER['QUERY_STRING'], $_GET); 

这会将变量放回 GET 数组中.

Which will put the variables back into the GET array.

这篇关于使用 CodeIgniter 获取 URL 中的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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