Page 1 of 1
url
Posted: Mon Dec 29, 2003 5:25 pm
by nincha
any way to get the current url and set it to a variable?
Posted: Mon Dec 29, 2003 5:58 pm
by microthick
If you need the whole url, including url parameters, you can use JavaScript.
Specifically, window.location.search holds the whole url.
<script language="JavaScript">
document.write('The URL is' + window.location.search);
</script>
Posted: Mon Dec 29, 2003 6:03 pm
by nincha
didnt seem to work
Posted: Mon Dec 29, 2003 6:08 pm
by microthick
<script language="JavaScript">
document.write('The URL is' + window.location.href);
</script>
window.location.search actually only returns the url parameters.
Posted: Mon Dec 29, 2003 6:09 pm
by Gen-ik
I take it you want this done in PHP?
Code: Select all
<?php
$page = $_SERVER["PHP_SELF"];
$uri = $_SERVER["REQUEST_URI"];
echo "{$page}<hr />{$uri}";
?>
Posted: Mon Dec 29, 2003 6:10 pm
by microthick
Gen-ik wrote:I take it you want this done in PHP?
Code: Select all
<?php
$page = $_SERVER["PHP_SELF"];
$uri = $_SERVER["REQUEST_URI"];
echo "{$page}<hr />{$uri}";
?>
I've never used REQUEST_URI. Does it return the whole url, including url parameters?
Posted: Mon Dec 29, 2003 6:16 pm
by nincha
thnx alot u guys!
Posted: Mon Dec 29, 2003 6:52 pm
by Gen-ik
microthick wrote:Gen-ik wrote:I take it you want this done in PHP?
Code: Select all
<?php
$page = $_SERVER["PHP_SELF"];
$uri = $_SERVER["REQUEST_URI"];
echo "{$page}<hr />{$uri}";
?>
I've never used REQUEST_URI. Does it return the whole url, including url parameters?
Yep it sure does

Posted: Tue Dec 30, 2003 2:48 am
by m3mn0n
If you run the following script:
Code: Select all
<?php
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
?>
You'll discover a few more that work similar.
Posted: Tue Dec 30, 2003 2:57 am
by Nay
mMm.......what's the difference between URI and URL? Uniform Resource Locator and Uniform Resource ur.......Inspector?
*hangs head in shame*
-Nay
Posted: Tue Dec 30, 2003 2:57 am
by m3mn0n
Yup. They're pretty much the same thing.
Posted: Tue Dec 30, 2003 4:38 am
by Derfel Cadarn
Hey Nay, now you've disappointed me!
Read
this uri-clarification, there are URN's too! Great!
I'm waiting for the URQ's....