Home >Backend Development >PHP Tutorial >PHP gets the URL of the current page, php gets the current page_PHP tutorial

PHP gets the URL of the current page, php gets the current page_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:09:231250browse

PHP gets the URL of the current page, php gets the current page

PHP gets the URL of the current page

<span>function</span><span> GetCurUrl()
{
  </span><span>$url </span>= 'http://'<span>;

  </span><span>if</span>(<span>isset</span>(<span>$_SERVER</span>['HTTPS']) AND <span>$_SERVER</span>['HTTPS'] == 'on'<span>)
  {
    </span><span>$url</span> = 'https://'<span>;
  }

  </span><span>if</span>(<span>$_SERVER</span>['SERVER_PORT'] != '80'<span>)
  {
    </span><span>$url</span> .= <span>$_SERVER</span>['HTTP_HOST'].':'.<span>$_SERVER</span>['SERVER_PORT'].<span>$_SERVER</span>['REQUEST_URI'<span>];
  }
  </span><span>else</span><span>
  {
    </span><span>$url</span> .= <span>$_SERVER</span>['HTTP_HOST'].<span>$_SERVER</span>['REQUEST_URI'<span>];
  }
  </span><span>return</span> <span>$url</span><span>;
}</span>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/946201.htmlTechArticlePHP gets the URL of the current page, php gets the URL of the current page PHP gets the URL of the current page function GetCurUrl(){ $url = 'http://' ; if ( isset ( $_SERVER ['HTTPS']) AND $_SERVER ['HTTPS']...
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