In PHP we want to get the current page full URL address need to use a few common PHP global variables function, mainly with $_server[] These variables, I will show you a get the current page full URL address program bar.
First look at some
$_server['
When using PHP to write a program, we often want to get the URL of the current page. The following provides a function to get the current page URL and how to use it:Example One:
After you define the function, you can call it directly:
PHP gets the current full URL address of the function, PHP gets the current URL
Here is mainly to share a very useful PHP function, the code is very simple, there is no more nonsense, the small partners need to use the words directly.
Copy the Code
PHP/** * JavaScript implementation: * Top.location.href the address of the top-level window * This.location.href The address of the current window*///PHP implementation//Test URL: http://localhost/blog/testurl.php?id=5//Get domain name or host
JavaScript implementations:Top.location.href The address of the top-level windowThis.location.href The address of the current windowPHP implementation#Test URL: http://localhost/blog/testurl.php?id=5//get the domain name or host addressEcho
JavaScript implementation: Top. location.href top-level window address this. location.href address of the current window#Test URL: http://localhost/blog/testurl.php?id=5//get the domain name or host addressEcho $_server[' Http_host ']. "
JavaScript implementations:Top.location.href The address of the top-level windowThis.location.href The address of the current windowPHP implementation#Test URL: http://localhost/blog/testurl.php?id=5Get domain name or host addressEcho$_server['
Turn around.Assuming the current page full address is: Http://www.test.com:80/aaa/bbb.aspx?id=5&name=kelli"/HTTP" is the protocol name"Www.test.com" is the domain name"80" is the port number"AAA" is the station name."Bbb.aspx" is the page name (file
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.