Home  >  Article  >  Backend Development  >  How to get website domain name and address using PHP

How to get website domain name and address using PHP

不言
不言Original
2018-06-22 11:37:334246browse

This article mainly introduces how to use PHP to obtain the website domain name and address. It has certain reference value. Now I share it with you. Friends in need can refer to

Function extracted from phpmyadmin

<? 
function PMA_getenv($var_name) { 
if (isset($_SERVER[$var_name])) { 
return $_SERVER[$var_name]; 
} elseif (isset($_ENV[$var_name])) { 
return $_ENV[$var_name]; 
} elseif (getenv($var_name)) { 
return getenv($var_name); 
} elseif (function_exists(&#39;apache_getenv&#39;) 
&& apache_getenv($var_name, true)) { 
return apache_getenv($var_name, true); 
} 
return &#39;&#39;; 
} 
if (empty($HTTP_HOST)) { 
if (PMA_getenv(&#39;HTTP_HOST&#39;)) { 
$HTTP_HOST = PMA_getenv(&#39;HTTP_HOST&#39;); 
} else { 
$HTTP_HOST = &#39;&#39;; 
} 
} 
echo htmlspecialchars($HTTP_HOST); 
?>

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to generate short URLs in php

About PHP – Introduction to EasyUI DataGrid data storage method

The above is the detailed content of How to get website domain name and address using 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