parseha parseha - 1 year ago 93
PHP Question

How get data from string like query string with php?

I have url like this

  1. index.php?name=aya&age=29

  2. 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?

aya aya
Answer Source

first use $_SERVER['QUERY_STRING'] to get querystring from url and then get data from string via parse_str function.

$str = str_replace(":","=",$str);
parse_str($str, $get);
echo $get['name'];
echo $get['age'];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download