Welcome, Guest: 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 - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Get Current Page URL In PHP (852 Views)

Get Current Page URL In PHP / How To Change Magento 2 Product Page URL? / Show Image From HTTP URL In React Native (2) (3) (4)

(1) (Reply)

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 .

1 Like

(1) (Reply)

Please I Need A 3-6 Years Old Facebook Account. Contact Me! / Jakonde Programmers / Help: Unable To Complete Previous Operation Due To Low Memory

(Go Up)

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

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2022 Oluwaseun Osewa. All rights reserved. See How To Advertise. 38
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.