如何从url参数中读取Get值[关闭]

How can I read value in get parameter

http://www.localhost/type=Cars,-Vans-&-SUVs

When I am trying to read type value from get URL I am not able to read from &.

Please suggest how to read type variable value in Get method.

the problem is , that & is a delimiter between GET-Keys.

You have to urlencode the value of the "type" or any other key in your URL:

Cars,-Vans-&-SUVs

is urlencoded:

Cars%2C-Vans-%26-SUVs

if you try to get the value, only urldecode the value.

In PHP the functions are urlencode() and urldecode().

You should have a ? sign before the GET parameters so if you want your type to be cars, the link should be:

http://www.localhost/?type=cars

If you need more than one parameter you should add it with an & sign

http://www.localhost/?type=cars&wheels=4

From your php file you then read the variables with $_GET[]

$type = $_GET['type'];
$wheels = $_GET['wheels'];

If you want all three types inside type parameter you should use

http://www.localhost/?type=Cars,-Vans-%26-SUVs

Update:

With:

?type=Cars,-Vans-%26-SUVs

the result array is:

[type] => Cars,-Vans-&-SUVs