手机
当前位置:查字典教程网 >编程开发 >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中使用sockets:从新闻组中获取文章

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

JavaScript实现滚动栏效果的方法

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

php实现TCP端口检测的方法

php实现将上传word文件转为html的方法

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

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

PHP基于MySQL数据库实现对象持久层的方法

php替换字符串中间字符为省略号的方法

精品推荐
分类导航