How to get the current domain name in PHP

小云云
Release: 2023-03-22 06:00:02
Original
8723 people have browsed it

This article mainly shares with you the method of obtaining the current domain name in PHP. It mainly shares with you a small piece of code. I hope it can help you.

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

Related recommendations:

How to use JS to determine the current domain name and jump to the specified page

php gets the current domain name and path

php gets the current domain name: PHP gets the current URL domain name

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!

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!