- <?php
- if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
- $url = "https://";
- else
- $url = "http://";
- // Append the host(domain name, ip) to the URL.
- $url.= $_SERVER['HTTP_HOST'];
- // Append the requested resource location to the URL
- $url.= $_SERVER['REQUEST_URI'];
- echo $url;
- ?>
or
- <?php
- $protocol = ((!emptyempty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
- $CurPageURL = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
- echo "The URL of current page: ".$CurPageURL;
- ?>
to get the current page url
- <?php
- $curPageName = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
- echo "The current page name is: ".$curPageName;
- echo "</br>";
- ?>
No comments:
Post a Comment