Bohne
asked on
window.location.search in php?!?
Hi,
how can I get the variable after the ? in the address line? (phptest.php?variable) In javascript it's window.location.search. But how is it called in php? Or is this not possible in php, because php is server based???
thanks
how can I get the variable after the ? in the address line? (phptest.php?variable) In javascript it's window.location.search. But how is it called in php? Or is this not possible in php, because php is server based???
thanks
Then you can use the parse() function to get all of the variables in the format of:
?variable=something?variab le2=othert hing
?variable=something?variab
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Alakriti.
That is absolutely right for name/value pairs.
But it doesn't work for ...
www.site.com/page.php?var1&var2&var3
Richard.
That is absolutely right for name/value pairs.
But it doesn't work for ...
www.site.com/page.php?var1&var2&var3
Richard.
Oops. I'm wrong.
The variables ARE processed into $_GET / $HTTP_GET_VARS, but without values!
So,
print_r($_GET);
returns
Array
(
"var1" =>
"var2" =>
)
You would be able to use ...
foreach($_GET as $key => $value)
{
echo "The variable '$key' was supplied with the value '$value'.\n";
}
to get to each variable sent.
Richard.
The variables ARE processed into $_GET / $HTTP_GET_VARS, but without values!
So,
print_r($_GET);
returns
Array
(
"var1" =>
"var2" =>
)
You would be able to use ...
foreach($_GET as $key => $value)
{
echo "The variable '$key' was supplied with the value '$value'.\n";
}
to get to each variable sent.
Richard.
$_SERVER['QUERY_STRING'];
For a complete list of available variables, try ...
<?php phpinfo(); ?>
Richard.