手机
当前位置:查字典教程网 >编程开发 >php教程 >Symfony2实现在controller中获取url的方法
Symfony2实现在controller中获取url的方法
摘要:本文实例讲述了Symfony2实现在controller中获取url的方法。分享给大家供大家参考,具体如下://假设当前URL地址是http...

本文实例讲述了Symfony2实现在controller中获取url的方法。分享给大家供大家参考,具体如下:

// 假设当前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');

希望本文所述对大家基于Symfony框架的PHP程序设计有所帮助。

【Symfony2实现在controller中获取url的方法】相关文章:

PHP实现即时输出、实时输出内容方法

Yii获取当前url和域名的方法

php中smarty实现多模版网站的方法

php转换颜色为其反色的方法

php循环table实现一行两列显示的方法

php中smarty区域循环的方法

php实现比较两个字符串日期大小的方法

php实现TCP端口检测的方法

PHP+shell实现多线程的方法

php按单词截取字符串的方法

精品推荐
分类导航