Return to Snippet

Revision: 3217
at June 19, 2007 12:27 by llbbl


Updated Code
$a = $_SERVER['HTTP_HOST'] // server-name - domain
$b = $_SERVER['PHP_SELF'] // you're page, as you know
$c = $_SERVER['QUERY_STRING'] // everything after the "?",
// but not including the "?"

echo "$a$b?$c";  // would print whole URL

$d = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
// notice the "?" in middle of the above, and variables seprated by dots(.)
// $_SERVER['QUERY_STRING'] reads url GET query, but does not contain
// the "?" in it itself, since "?" is not a variable.

echo $d; // would print the whole URL using above.

Revision: 3216
at June 19, 2007 12:26 by llbbl


Initial Code
$a = $_SERVER['HTTP_HOST'] // server-name - domain
$b = $_SERVER['PHP_SELF'] // you're page, as you know
$c = $_SERVER['QUERY_STRING'] // everything after the "?",
// but not including the "?"

echo "$a$b?$c";  // would print whole URL

$d = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
// notice the "?" in middle of the above, and variables seprated by dots(.)
// $_SERVER['QUERY_STRING'] reads url GET query, but does not contain
// the "?" in it itself, since "?" is not a variable.

echo $d; // would print the whole URL using above.

Initial URL

                                

Initial Description

                                

Initial Title
URL Manipulation

Initial Tags
url, php, textmate, server

Initial Language
PHP