本文实例讲述了Symf@本文9来源gao($daima.com搞@代@#码8网^搞代gaodaima码ony实现行为和模板中取得request参数的方法。分享给大家供大家参考,具体如下:
一.模板中取得参数
getParameter('name','namespace');?>getParameter('name');?>
二.行为中取得参数
$request->getParameter('name');//模板中取得参数get('name')?>//带默认值的参数get('name','default')?>//在模板中判断一个参数是否存在has('name')): ?><p>Hello,get('name')?>!</p><p>Hello,JohnDoe!</p>//包含所有参数的数组$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程序设计有所帮助。