/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Returns the full URL of the current document. function getCurrentUrl() { // Checks scheme. $url = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; // Checks port. $url .= ($_SERVER['SERVER_PORT'] != '80') ? $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'] : $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; // Returns full URL. return $url; }