Maison >développement back-end >tutoriel php >PHP获取当前页面的因特网址

PHP获取当前页面的因特网址

WBOY
WBOYoriginal
2016-06-13 12:13:551015parcourir

PHP获取当前页面的网址

PHP获取当前页面的网址

<span style="color: #0000ff;">function</span><span style="color: #000000;"> GetCurUrl(){  </span><span style="color: #800080;">$url </span>= 'http://'<span style="color: #000000;">;  </span><span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_SERVER</span>['HTTPS']) AND <span style="color: #800080;">$_SERVER</span>['HTTPS'] == 'on'<span style="color: #000000;">)  {    </span><span style="color: #800080;">$url</span> = 'https://'<span style="color: #000000;">;  }  </span><span style="color: #0000ff;">if</span>(<span style="color: #800080;">$_SERVER</span>['SERVER_PORT'] != '80'<span style="color: #000000;">)  {    </span><span style="color: #800080;">$url</span> .= <span style="color: #800080;">$_SERVER</span>['HTTP_HOST'].':'.<span style="color: #800080;">$_SERVER</span>['SERVER_PORT'].<span style="color: #800080;">$_SERVER</span>['REQUEST_URI'<span style="color: #000000;">];  }  </span><span style="color: #0000ff;">else</span><span style="color: #000000;">  {    </span><span style="color: #800080;">$url</span> .= <span style="color: #800080;">$_SERVER</span>['HTTP_HOST'].<span style="color: #800080;">$_SERVER</span>['REQUEST_URI'<span style="color: #000000;">];  }  </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$url</span><span style="color: #000000;">;}</span>

 

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn