Page 1 of 1

Get the entire address in the address bar in PHP

Posted: Mon Feb 25, 2008 7:09 pm
by madjamonline
Hello all.
This is a very basic script I have put up and it does work.

Requirements:
Web server that supports PHP!

This is what you do:

Code: Select all

<?php
// Code by Jamie

if($_SERVER['QUERY_STRING'] == "")
{
$query_questionmark = "";
}
else
{
$query_questionmark = "?";
}
$pageaddress= "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].$_SERVER['PHP_SELF'].$query_questionmark.$_SERVER['QUERY_STRING'];

// Done!
?> 
and the address will be stored in the var pageaddress.

If you enter the code above and want to write the page address on the page, add this underneath it.

Code: Select all

<?php
echo $pageaddress;
?>
: EDIT :
If however you want to remove certain bits in the code feel free to do so.


I hope the code is helpful!
Please give me comments!

Many thanks, :D