|Register On Nairaland / LOGIN! / Trending / Recent / New|
Stats: 2,909,412 members, 7,017,429 topics. Date: Monday, 15 August 2022 at 04:42 AM
|Get Current Page URL In PHP by skptricks: 3:02am On Mar 08, 2018|
Get more details : Get current page URL in PHP
In this tutorial, we are going to discuss how to get current page URL using PHP. $_SERVER is a super global variable, which is always available in all scopes. We will use $_SERVER variable to get the current page URL. It is an array contains various information such as, headers, document path, script location, request method etc.
Explanation about some useful $_SERVER variable :
$_SERVER['HTTP_HOST'] : Contents of the Host header from the current request, if there is one.
$_SERVER['PHP_SELF'] : The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://skptricks.com/post/php-tutorial.php would be /post/php-tutorial.php.
$_SERVER['QUERY_STRING'] : If a page is accessed via any query string, $_SERVER['QUERY_STRING'] fetches that query string.This is a actual URL http://localhost/skptricks/check current page url/currentPageURL.php?jj=kkkk after the $_SERVER['QUERY_STRING'] operation would be jj=kkkk .
|Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health |
religion celebs tv-movies music-radio literature webmasters programming techmarket
Nairaland - Copyright © 2005 - 2022 Oluwaseun Osewa. All rights reserved. See How To Advertise. 38