Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,750 members, 7,820,587 topics. Date: Tuesday, 07 May 2024 at 05:43 PM

Get Current Page URL In PHP - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Get Current Page URL In PHP (948 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)

Needs A WPF Programmer Based In Abuja / I Need Help / Regarding For DBMS Query!

(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 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.