If you need to get the last part of a url of the page you are in, the code below will show you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?php $uri = $_SERVER['REQUEST_URI']; echo "<br>1".$uri; // Outputs: URI $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; echo "<br>2".$url; // Outputs: Full URL $query = $_SERVER['QUERY_STRING']; echo "<br>3".$query; // Outputs: Query String ?> |
1 2 3 4 |
$path = basename($_SERVER['HTTP_REFERER']); echo $path; |
Shows loop.php