加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

Symfony实现行为和模板中取得request参数的方法

发布时间:2020-05-25 14:29:11 所属栏目:PHP 来源:互联网
导读:这篇文章主要介绍了Symfony实现行为和模板中取得request参数的方法,实例分析了Symfony针对行为和方法中参数获取的技巧,需要的朋友可以参考下

本文实例讲述了Symfony实现行为和模板中取得request参数的方法。分享给大家供大家参考,具体如下:

一.模板中取得参数

getParameter('name','namespace');?> getParameter('name');?>

二.行为中取得参数

getParameter('name'); //模板中取得参数 get('name')?> //带默认值的参数 get('name','default')?> //在模板中判断一个参数是否存在 has('name')): ?>

Hello,get('name')?>!

Hello,JohnDoe!

//包含所有参数的数组 $request->getParameterHolder()->getAll() //完整的URI路径 //'http://localhost/myapp_dev.php/mymodule/myaction' getUri() //'/mymodule/myaction' getPathInfo() //在action中 $hasFoo =$this->getRequest()->hasParameter('foo'); $hasFoo = $this->hasRequestParameter('foo');//Shorter version $foo =$this->getRequest()->getParameter('foo'); $foo =$this->getRequestParameter('foo'); //Shorterversion

希望本文所述对大家基于Symfony框架的PHP程序设计有所帮助。

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读