手机
当前位置:查字典教程网 >编程开发 >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中smarty实现多模版网站的方法

PHP使用flock实现文件加锁的方法

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

php curl 获取https请求的2种方法

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

PHP+shell实现多线程的方法

php实现TCP端口检测的方法

php实现统计网站在线人数的方法

CodeIgniter针对lighttpd服务器URL重写的方法

令你的网站获得任意Google PR值的方法

精品推荐
分类导航