《PHP實(shí)戰(zhàn):Symfony2實(shí)現(xiàn)在controller中獲取url的方法》要點(diǎn):
本文介紹了PHP實(shí)戰(zhàn):Symfony2實(shí)現(xiàn)在controller中獲取url的方法,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
PHP實(shí)例本文實(shí)例講述了Symfony2實(shí)現(xiàn)在controller中獲取url的辦法.分享給大家供大家參考,具體如下:
PHP實(shí)例
// 假設(shè)當(dāng)前URL地址是http://192.168.1.100/demo/web/app_dev.php/m/index
$request = $this->getRequest();
// http or https 此處為http
$request->getScheme();
// 192.168.1.100
$request->getHttpHost();
// http://192.168.1.100
$request->getSchemeAndHttpHost();
// /demo/web/
$request->getBasePath();
// /demo/index.php
$request->getBaseUrl();
// eg: /demo/web/app_dev.php/user/login 不一定是/demo/web/app_dev.php/m/index 取決于routeName
$this->generateUrl('routeName');
// routeName
$routeName = $request->get('_route');
PHP實(shí)例希望本文所述對(duì)大家基于Symfony框架的PHP程序設(shè)計(jì)有所贊助.
歡迎參與《PHP實(shí)戰(zhàn):Symfony2實(shí)現(xiàn)在controller中獲取url的方法》討論,分享您的想法,維易PHP學(xué)院為您提供專業(yè)教程。
轉(zhuǎn)載請(qǐng)注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/7313.html