URL help
Moderator: General Moderators
URL help
How do I get my file to get the current URL (that is being viewed), parse it and display only the variable to the page?
-
pootergeist
- Forum Contributor
- Posts: 273
- Joined: Thu Feb 27, 2003 7:22 am
- Location: UK
echo $_SERVER['REQUEST_URI'];
that'll output the current top document request call (query string included)
next bit...
just output the variable ? or the value of the variable ?
foreach($_GET as $var=>$val)
{
echo $var.'<br />';
}
well, that's the get variables echoed. If you didn't mean that, please explain better.
that'll output the current top document request call (query string included)
next bit...
just output the variable ? or the value of the variable ?
foreach($_GET as $var=>$val)
{
echo $var.'<br />';
}
well, that's the get variables echoed. If you didn't mean that, please explain better.
$_SERVER['QUERY_STRING'] might be what you're looking for - or the $_GET array, as mentioned above.
See php manual "predefined variables" for full info.
Re the code above:
Isn't that just echoing out the keys?
If you want to declare the vars (you might not need to) try:
You might want to do some processing on GET vars for security reasons but I'm still figuring that out.
See php manual "predefined variables" for full info.
Re the code above:
Code: Select all
foreach($_GET as $var=>$val)
{
echo $var.'<br />';
}If you want to declare the vars (you might not need to) try:
Code: Select all
foreach($_GET as $var=>$val)
{
$$var = $val;
}
Last edited by McGruff on Thu Aug 11, 2005 2:20 pm, edited 1 time in total.
Thank you for your help.
This is what worked:
http://www.site.com?number=3
echo $_GET['number'];
------displays------------
3
This is what worked:
http://www.site.com?number=3
echo $_GET['number'];
------displays------------
3