Symfony2实现在controller中获取url的方法

前端之家收集整理的这篇文章主要介绍了Symfony2实现在controller中获取url的方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

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程序设计有所帮助。

原文链接:https://www.f2er.com/php/20179.html

猜你在找的PHP相关文章