How does Slim framework get the current url?

WBOY
Release: 2016-08-30 09:36:44
Original
1265 people have browsed it

1. During the process of building the code, you need to obtain the current website domain name, which is similar to the base_url() function in CI
2. I searched the documentation and did not see any similar functions available
3. Because there is no I really want to try the SERVER global variable that comes with PHP to get the current domain name,
So I want to ask if Slim provides such a function

Reply content:

1. During the process of building the code, you need to obtain the current website domain name, which is similar to the base_url() function in CI
2. I searched the documentation and did not see any similar functions available
3. Because there is no I really want to try the SERVER global variable that comes with PHP to get the current domain name,
So I want to ask if Slim provides such a function

Yes.

<code class="php">$request->getUri()->getBaseUrl()</code>
Copy after login

getUri This method will return a Uri object, the class is under Http, you can take a look

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!