Home >Backend Development >PHP Tutorial >How to get the current domain name in PHP

How to get the current domain name in PHP

不言
不言Original
2018-04-26 14:28:2511454browse

This article mainly introduces how to obtain the current domain name in PHP. Friends in need can refer to it

[php] view plain copy
<?  
//获取当前的域名:  
echo $_SERVER[&#39;SERVER_NAME&#39;];  
//获取来源网址,即点击来到本页的上页网址  
echo $_SERVER["HTTP_REFERER"];  
$_SERVER[&#39;REQUEST_URI&#39;];//获取当前域名的后缀  
$_SERVER[&#39;HTTP_HOST&#39;];//获取当前域名  
dirname(__FILE__);//获取当前文件的物理路径  
dirname(__FILE__)."/../";//获取当前文件的上一级物理路径  
?>


The above is the detailed content of How to get the current domain name in PHP. For more information, please follow other related articles on the PHP Chinese website!

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