這篇文章將為大家詳細(xì)講解有關(guān)Symfony如何實(shí)現(xiàn)行為和模板中取得request參數(shù),小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

具體如下:
一.模板中取得參數(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')?>
//帶默認(rèn)值的參數(shù)
<?php echo $sf_params->get('name','default')?>
//在模板中判斷一個(gè)參數(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關(guān)于“Symfony如何實(shí)現(xiàn)行為和模板中取得request參數(shù)”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
當(dāng)前名稱:Symfony如何實(shí)現(xiàn)行為和模板中取得request參數(shù)-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)網(wǎng)址:http://chinadenli.net/article10/ecodo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、移動(dòng)網(wǎng)站建設(shè)、域名注冊(cè)、手機(jī)網(wǎng)站建設(shè)、品牌網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容