欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Symfony實現(xiàn)行為和模板中取得request參數(shù)的方法

 更新時間:2016年03月17日 12:01:30   作者:智足者富  
這篇文章主要介紹了Symfony實現(xiàn)行為和模板中取得request參數(shù)的方法,實例分析了Symfony針對行為和方法中參數(shù)獲取的技巧,需要的朋友可以參考下

本文實例講述了Symfony實現(xiàn)行為和模板中取得request參數(shù)的方法。分享給大家供大家參考,具體如下:

一.模板中取得參數(shù)

<?php echo $sf_request->getParameter('name','namespace');?>
<?php echo $sf_request->getParameter('name');?>

二.行為中取得參數(shù)

$request->getParameter('name');
//模板中取得參數(shù)
<?php echo $sf_params->get('name')?>
//帶默認值的參數(shù)
<?php echo $sf_params->get('name','default')?>
//在模板中判斷一個參數(shù)是否存在
<?php if($sf_params->has('name')): ?>
<p>Hello,<?php echo $sf_params->get('name')?>!</p>
<?php else: ?>
<p>Hello,JohnDoe!</p>
<?php endif; ?>
//包含所有參數(shù)的數(shù)組
$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程序設(shè)計有所幫助。

相關(guān)文章

最新評論