I have url like this
- index.php?name=aya&age=29
- index.php?name:aya&age:29
I want get name and age from this url.
I think if i can get query string, perhaps i can render it.
How can do it?
1 Answer 1
first use $_SERVER['QUERY_STRING']
to get querystring
from url
and then get data from string via parse_str function.
code:
$str = $_SERVER['QUERY_STRING'];
$str = str_replace(":","=",$str);
parse_str($str, $get);
echo $get['name'];
echo $get['age'];
answered Jun 15, 2016 at 18:56
lang-php