JavaScript implementations:Top.location.href The address of the top-level windowThis.location.href The address of the current windowPHP implementation#测试网址: http://localhost/blog/testurl.php?id=5echo $_server[' Http_host ']. " ";
JavaScript implements TOP.LOCATION.HREF the address of the top-level window This.location.href The address document of the current window. URL PHP implementation # Test URL: http://localhost/blog/testurl.php?id=5//get the domain name or host
JavaScript implementationtop.location. the address of the HREF top-level window This . Location.href the address of the current windowPHP implementation#测试网址: http://localhost/blog/testurl.php?id=5Get the domain name or host address echo $_server['
Here is mainly to share a very useful PHP function, the code is very simple, not much nonsense, the small partners need to use the words directly.
Copy Code code as follows:
PHP gets the full URL address of the current access
function
Assuming the full address of the current page is: http://blog.csdn.net/hashxu/article.aspx?Action=Get&PostId=6858577
"1" gets the full URL
String url=request.url.tostring ();
Url= http://blog.csdn.net/hashxu/article.aspx?Action=Get&PostId=6858577
JavaScript implementation:
Copy Code code as follows:
Top.location.href the address of the top-level window this.location.href the address of the current window
PHP Implementation:
Copy Code code as follows:
PHP Gets the current page full real URL address method, including parameters, summed up three methods, you can choose according to the needs, the specific function code is as follows:
The first method:
function Getcururl () {if (Isset ($_server['
The main is to get to the address bar some information, domain name, port parameters, etc.
Copy Code code as follows:
Get domain name or host address
echo $_server[' Http_host ']. " ";
Get Web page address
echo $_server['
The example in this article describes how Python implements a complete URL segmentation. Share to everyone for your reference. The specific analysis is as follows:
Python splits a complete URL into separate parts, including protocols, domain names,
The main is to get to the address bar some information, domain names, port parameters, etc.
Copy CodeThe code is as follows:
Get domain name or host address
echo $_server[' Http_host ']. "
";
Get web Address
echo $_server[' php_self ']. "
";
Get
Environment: Python2.7.9/sublime Text 2/chrome1.url access, call the Urllib library function directlyImport urllib2url='http://www.baidu.com/'= urllib2.urlopen (URL) HTML =response.read ()print html2. Access with parameters, with the Baidu search
PHP get current page address multiple methodsThere are a number of ways to get the current page address in PHP, including some examples of collected tutorials, recorded.Reference Tutorial:Get the full URL of the current page in PHPPHP three ways to
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.