Home  >  Article  >  Backend Development  >  php gets current page address

php gets current page address

WBOY
WBOYOriginal
2016-07-30 13:29:531269browse

Suddenly can’t find what you want to use?

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

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

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

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

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.

Statement:
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