Home > Backend Development > PHP Tutorial > php gets current page address

php gets current page address

WBOY
Release: 2016-07-30 13:29:53
Original
1286 people have browsed it

Suddenly can’t find what you want to use?

$_SERVER['HTTP_HOST']//获取域名或主机地址 
Copy after login

$_SERVER['PHP_SELF']//获取网页地址
Copy after login

$_SERVER["QUERY_STRING"]//获取网址参数 
Copy after login
If you want to output, add 'http://' in front of it
.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];//获取完整的url
Copy after login

$url='http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]; 
echo dirname($url);//只取路径
Copy after login

Summary: In fact, I usually only use the URL parameters to make a judgment. Others are irrelevant. I hope it can help you. Bar.

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces how to get the current page address in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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