超薄3-如何获得所有的GET/PUT/POST变量? [英] Slim 3 - how to get all get/ put/ post variables?
本文介绍了超薄3-如何获得所有的GET/PUT/POST变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获得所有get/ put/ post
变量,就像在Slim 2 for Slim 3中一样?
超薄2,
$allGetVars = $app->request->get();
$allPutVars = $app->request->put();
$allPostVars = $app->request->post();
如何在超薄3中做到这一点?
,例如http://example.com/books/1?title=hello&content=world
现在如何在超薄3中获取title
和content
中的参数?
超薄2,
$title = $app->request->get('title');
$content = $app->request->get('content');
如何在超薄3中做到这一点?
推荐答案
获取全部get/put/post
参数:
//GET
$allGetVars = $request->getQueryParams();
foreach($allGetVars as $key => $param){
//GET parameters list
}
//POST or PUT
$allPostPutVars = $request->getParsedBody();
foreach($allPostPutVars as $key => $param){
//POST or PUT parameters list
}
单参数值:
//Single GET parameter
$getParam = $allGetVars['title'];
//Single POST/PUT parameter
$postParam = $allPostPutVars['postParam'];
这篇关于超薄3-如何获得所有的GET/PUT/POST变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文