/ Published in: PHP
This script will return the URL for the current page you're on, including category and tag pages.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } ?> <?php echo curPageURL(); ?>
URL: http://dailypaste.wordpress.com/2008/10/26/php-get-current-url/