如何在CAKEPHP中访问GET请求? [英] How can I access a GET request in CAKEPHP?
本文介绍了如何在CAKEPHP中访问GET请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在CAKEPHP中访问GET请求?
How can I access a GET request in CAKEPHP ?
如果我在URL中传递一个变量
If I am passing a variable in the url
http://samplesite.com/page?key1=value1&key2=value2
我应该使用$ _GET还是$ this-> params来获取控制器中的值?
CAKEPHP中的标准是什么?
Should I use $_GET or $this->params to get the values in controller? What is the standard in CAKEPHP ?
推荐答案
在Cake中执行此操作的标准方法是使用 $ this-> params
。
The standard way to do this in Cake is to use $this->params
.
$value1 = $this->params['url']['key1'];
$value2 = $this->params['url']['key2'];
根据CakePHP的书,$ this-> params最常用的用法是访问信息已经通过GET或POST操作交给控制器。
According to the CakePHP book, "the most common use of $this->params is to access information that has been handed to the controller via GET or POST operations."
请参阅此处。
这篇关于如何在CAKEPHP中访问GET请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文