简体   繁体   中英

How to get the symbol of plus as it is from $_REQUEST - regular expressions?

How to pass the symbol of plus + as it is when you want to pass it into $_REQUEST?

For instance, I want to pass this,

xxx.php?key=xPo8lUEXpqg8bKL+32o6yIOK

and I want to get xPo8lUEXpqg8bKL+32o6yIOK in echo $_REQUEST['key']; but I will get this below instead -

xPo8lUEXpqg8bKL 32o6yIOK

What should I do to fix this? Regular expressions again??

Thanks.

You need to use %2B instead of + , as + is the URL-encoded symbol for a space. In general, you should use urlencode() to escape things properly:

$url = "xxx.php?key=" . urlencode('xPo8lUEXpqg8bKL+32o6yIOK');

+ is a reserved character in a URL and decodes to a space.

Do a urlencode() on the string before attaching it to the URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM