Home > Article > Backend Development > How to get website domain name and address using PHP
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('apache_getenv') && apache_getenv($var_name, true)) { return apache_getenv($var_name, true); } return ''; } if (empty($HTTP_HOST)) { if (PMA_getenv('HTTP_HOST')) { $HTTP_HOST = PMA_getenv('HTTP_HOST'); } else { $HTTP_HOST = ''; } } 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!