How to get page url with php
Posted by in PhpI needed a function to get (learn) url with php.
Here are the codes.
<?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;
}
?>
To use this function write
<? echo curPageURL(); ?>
Related posts
You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

it is very long technique.