Home  >  Article  >  Backend Development  >  解析PHP获取当前网址及域名的实现代码_php技巧

解析PHP获取当前网址及域名的实现代码_php技巧

WBOY
WBOYOriginal
2016-05-17 08:59:31926browse
复制代码 代码如下:


//获取当前的域名:
echo $_SERVER['SERVER_NAME'];
//获取来源网址,即点击来到本页的上页网址
echo $_SERVER["HTTP_REFERER"];
$_SERVER['REQUEST_URI'];//获取当前域名的后缀
$_SERVER['HTTP_HOST'];//获取当前域名
dirname(__FILE__);//获取当前文件的物理路径
dirname(__FILE__)."/../";//获取当前文件的上一级物理路径
?>
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