Symfony2实现在controller中获取url的方法,symfony2controller
Symfony2实现在controller中获取url的方法,symfony2controller
本文实例讲述了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框架创建项目与模板设置实例详解
- 使用symfony命令创建项目的方法
- Symfony页面的基本创建实例详解
- symfony2.4的twig中date用法分析
- Symfony2之session与cookie用法小结
- Symfony2实现从数据库获取数据的方法小结
- Symfony2框架学习笔记之表单用法详解
- Symfony2框架学习笔记之HTTP Cache用法详解
- Symfony2学习笔记之插件格式分析
- Symfony2学习笔记之系统路由详解
- Symfony2学习笔记之控制器用法详解
- Symfony2学习笔记之模板用法详解
- Symfony2创建页面实例详解

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

1. The professions that can be changed to "Male Ghost Sword" are: Red Eye, Devil May Cry (Shura and Sword Soul have been launched in the Korean server, and are expected to be launched in the second batch) 2. The professions that can be changed to "Female Fighting" are: Sanda, Qigong 3. The professions that can be changed by "Male Gunner" are: Roaming, Gunslinger 4, and the professions that can be changed by "Female Magic" are: Elemental, Magic Scholar 5, and the professions that can be changed by "Female Priest" are: Paladin

When a SpringBoot novice creates a project, the Controller cannot be scanned for a series of problems 1.2.3.4.5.6. Another way is to add @ComponentScan(basePackages={"xxx.xxx.xx","xxx.xxx" when starting the service class) .xx”}) is the fully qualified name of the package, which can be used for multiple SpringBoot custom controllers. The SpringBoot custom controller route cannot be scanned and cannot be found because the startup class and the custom Controller package are not in the same directory. Officially recommended placement of application.java

PHP function introduction—get_headers(): Overview of obtaining the response header information of the URL: In PHP development, we often need to obtain the response header information of the web page or remote resource. The PHP function get_headers() can easily obtain the response header information of the target URL and return it in the form of an array. This article will introduce the usage of get_headers() function and provide some related code examples. Usage of get_headers() function: get_header

Since the release of the domestic game version in February, NetEase's mysterious shooting game "Operation Apocalypse" has attracted the curiosity of many players. As we all know, although NetEase also had some shooting games in the early years, it seems that except for "The Day After Tomorrow" and "Knives Out", there are not many playable games. In recent years, the works launched by NetEase have gained momentum and have achieved considerable results in many niche tracks. The fact that "Operation Apocalypse", which has never been exposed before, is placed as the first shot of NetEase in the new year is enough to raise eyebrows. Is this a signal that NetEase is going to launch an attack on the shooting track? Players are eagerly looking forward to new mobile shooting games. , on March 13, this 5V5 multi-hero skills shooting mobile game "Operation Apocalypse" developed by NetEase finally unveiled its mystery and officially released its first live demonstration

On March 25, the "Eternal Tribulation" mobile game conducted a preview live broadcast one month after receiving the version number. Producer Guan Lei personally demonstrated the actual game screen and core gameplay during the live broadcast. This is also the first time the real-life footage of the mobile game "Eternal Tribulation" has been released publicly. Judging from the live footage released, the mobile game "Eternal Tribulation" continues the core gameplay of the PC martial arts chicken game, and all mechanisms and techniques such as flying ropes, vibrating knives, and combos are also restored. In order to adapt to the operation of the mobile terminal, the mobile game has made drastic changes to the operation buttons. It retains the core gameplay of the terminal game while simplifying the operation of the mobile terminal. It innovatively uses the UI form of "roulette" operation: click to attack, Press and hold to charge, slide left to vibrate the sword, and slide up to raise the dragon. Various attack modes can be easily completed through different operations of one button, but still maintain

The reason for the error is NameResolutionError(self.host,self,e)frome, which is an exception type in the urllib3 library. The reason for this error is that DNS resolution failed, that is, the host name or IP address attempted to be resolved cannot be found. This may be caused by the entered URL address being incorrect or the DNS server being temporarily unavailable. How to solve this error There may be several ways to solve this error: Check whether the entered URL address is correct and make sure it is accessible Make sure the DNS server is available, you can try using the "ping" command on the command line to test whether the DNS server is available Try accessing the website using the IP address instead of the hostname if behind a proxy

Nowadays, many Windows users who love games have entered the Steam client and can search, download and play any good games. However, many users' profiles may have the exact same name, making it difficult to find a profile or even link a Steam profile to other third-party accounts or join Steam forums to share content. The profile is assigned a unique 17-digit id, which remains the same and cannot be changed by the user at any time, whereas the username or custom URL can. Regardless, some users don't know their Steamid, and it's important to know this. If you don't know how to find your account's Steamid, don't panic. In this article

Journey through the vastness and set foot on the journey to the west! Today, Zhengtu IP officially announced that it will launch a cross-border cooperation with CCTV animation "Journey to the West" to jointly create a cultural feast that combines tradition and innovation! This cooperation not only marks the in-depth cooperation between the two major domestic classic brands, but also demonstrates the unremitting efforts and persistence of the Zhengtu series on the road of promoting Chinese traditional culture. Since its birth, the Zhengtu series has been loved by players for its profound cultural heritage and diversified gameplay. In terms of cultural inheritance, the Zhengtu series has always maintained respect and love for traditional Chinese culture, and skillfully integrated traditional cultural elements into the game, bringing more fun and inspiration to players. The CCTV animation "Journey to the West" is a classic that has accompanied the growth of generations.
