Get host domain name function

WBOY
Release: 2016-07-25 09:09:32
Original
807 people have browsed it
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


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!