Home  >  Article  >  Backend Development  >  Get host domain name function

Get host domain name function

WBOY
WBOYOriginal
2016-07-25 09:09:32835browse
I found it through a search. I want to use it and post it to see if there are any problems!
echo $HTTP_HOST
This is the domain name to be exported!
  1. function PMA_getenv($var_name) {
  2. if (isset ( $_SERVER [$var_name] )) {
  3. return $_SERVER [$var_name];
  4. } elseif (isset ( $_ENV [$var_name] )) {
  5. return $_ENV [$var_name];
  6. } elseif (getenv ( $var_name )) {
  7. return getenv ( $var_name );
  8. } elseif (function_exists ( 'apache_getenv' ) && apache_getenv ( $var_name, true )) {
  9. return apache_getenv ( $var_name, true );
  10. }
  11. return '';
  12. }
  13. if (empty ( $HTTP_HOST )) {
  14. if (PMA_getenv ( 'HTTP_HOST' )) {
  15. $HTTP_HOST = PMA_getenv ( 'HTTP_HOST' );
  16. } else {
  17. $HTTP_HOST = '';
  18. }
  19. }
  20. echo htmlspecialchars ( $HTTP_HOST );
Copy code


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