Home >Backend Development >PHP Tutorial >There are many ways to get the current page address in php (with tutorial), php current_PHP tutorial

There are many ways to get the current page address in php (with tutorial), php current_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:17:371224browse

There are many ways to get the current page address in php (with tutorial), php is currently

There are many ways to get the current page address in php

Regarding the various methods of obtaining the current page address in PHP, including some collected example tutorials, record them.

Reference tutorial:

Get the complete URL of the current page in PHP

Three methods for php to obtain the address parameters of the current page

php obtain url address bar and detailed parameter example

Example of php getting the current domain name and url address

php gets the current URL address

Example of php getting the complete url address of the current page

PHP code:

<span>//</span><span>获取域名或主机地址 </span>
<span>echo</span> <span>$_SERVER</span>['HTTP_HOST']."<br>"; <span>#</span><span>localhost

//获取网页地址 </span>
<span>echo</span> <span>$_SERVER</span>['PHP_SELF']."<br>"; <span>#</span><span>/blog/testurl.php

//获取网址参数 </span>
<span>echo</span> <span>$_SERVER</span>["QUERY_STRING"]."<br>"; <span>#</span><span>id=5

//获取用户代理 </span>
<span>echo</span> <span>$_SERVER</span>['HTTP_REFERER']."<br>"<span>;

</span><span>//</span><span>获取完整的url www.jbxue.com</span>
<span>echo</span> 'http://'.<span>$_SERVER</span>['HTTP_HOST'].<span>$_SERVER</span>['REQUEST_URI'<span>];
</span><span>echo</span> 'http://'.<span>$_SERVER</span>['HTTP_HOST'].<span>$_SERVER</span>['PHP_SELF'].'?'.<span>$_SERVER</span>['QUERY_STRING'<span>];
</span><span>#</span><span>http://localhost/blog/testurl.php?id=5

//包含端口号的完整url</span>
<span>echo</span> 'http://'.<span>$_SERVER</span>['SERVER_NAME'].':'.<span>$_SERVER</span>["SERVER_PORT"].<span>$_SERVER</span>["REQUEST_URI"<span>]; 
</span><span>#</span><span>http://localhost:80/blog/testurl.php?id=5

//只取路径</span>
<span>$url</span>='http://'.<span>$_SERVER</span>['SERVER_NAME'].<span>$_SERVER</span>["REQUEST_URI"<span>]; 
</span><span>echo</span> <span>dirname</span>(<span>$url</span>);

Get the position of the current page, how to define the php function

Your database is all in order, Home Page - Product Center - Steel. Needless to say, you know this breadcrumb navigation home page. You are on the Steel page now. I believe you can easily access the upper-level column of Steel. You can get it!

The php function gets the url of the current page

You can take a look at this:
A.php:
97f2b6ae5f4f65bc7d15c6c9b9e8be8c
6c04bd5ca3fcae76e30b72ad730ca86d
1a42b2704b716ae8935c518fce584baaClick me first, then pay attention to the URL5db79b134e9f6b82c0b36e0489ee08ed
6c95344ebea791ad5d7a267e2012b89bClick I go to b.php5db79b134e9f6b82c0b36e0489ee08ed
36cc49f0c466276486e50c850b7e4956

B.php:

d04243bd66e85b0a40504125c6b7b86a
6c04bd5ca3fcae76e30b72ad730ca86d
9aad380cb694ea9748b6bf23ce28b531
36cc49f0c466276486e50c850b7e4956
------------------------------------------------ ----------------------------
.$_SERVER['HTTP_REFERER'];
Get the previous URL

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/891593.htmlTechArticleThere are many ways to get the current page address in php (with tutorial), there are many ways to get the current page address in php. There are many ways to get the current page address in php, including some examples collected...
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