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

WBOY
Release: 2016-07-13 10:09:23
Original
1229 people have browsed it

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>
Copy after login

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']...
Related labels:
php
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