如何在php中使用GET方法获取%20的url?

如何在php中使用GET方法获取%20的url?

问题描述:

I tried to use GET method in php, but the url has home%20phone as query parameter

When i tried to read it using

<?php echo $_GET['home%20phone']; ?>

it is not working..So, how to read variables like this.

thanks.

Do a var_dump($_GET) to see the keys the variables are mapped to.

%20 is a URL-encoded space character. Try this:

<?php echo $_GET['home phone']; ?>

If you're not sure what the keys in your array are, you can always use print_r($_GET) or var_dump($_GET) to see what's in there.

Use urldecode() for extracting exact value from the get method.

Refer: http://php.net/manual/en/function.urldecode.php

<?php echo urldecode($_GET['home%20phone']); ?>