《PHP實例:Symfony2中被遺棄的getRequest()方法分析》要點:
本文介紹了PHP實例:Symfony2中被遺棄的getRequest()方法分析,希望對您有用。如果有疑問,可以聯(lián)系我們。
本文實例分析了Symfony2中被遺棄的getRequest()辦法.分享給大家供大家參考,具體如下:PHP教程
最近使用Symfony時,在NetBeans中發(fā)現getRequest()辦法被遺棄了:PHP教程
/** * Shortcut to return the request service. * * @return Request * * @deprecated Deprecated since version 2.4, to be removed in 3.0. Ask * Symfony to inject the Request object into your controller * method instead by type hinting it in the method's signature. */ public function getRequest() { return $this->container->get('request_stack')->getCurrentRequest(); }
Google了一下,發(fā)現應該這么寫:PHP教程
use Symfony\Component\HttpFoundation\Request; public function updateAction(Request $request) { $foo = $request->get('foo'); $bar = $request->get('bar'); }
post方式請使用:PHP教程
$foo = $request->request->get('foo');
get方式請使用:PHP教程
$foo = $request->query->get('foo');
更多關于PHP相關內容感興趣的讀者可查看本站專題:《php操作office文檔技巧總結(包括word,excel,access,ppt)》、《php日期與時間用法總結》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數據庫操作入門教程》及《php常見數據庫操作技巧匯總》PHP教程
希望本文所述對大家PHP程序設計有所贊助.PHP教程
歡迎參與《PHP實例:Symfony2中被遺棄的getRequest()方法分析》討論,分享您的想法,維易PHP學院為您提供專業(yè)教程。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/7338.html