网址丢失加号

时间:2016-01-17 16:23:01

标签: php url

我意识到在URL中,+符号代表一个空格,但我需要保留加号。我怎样才能做到这一点?我的网址和代码如下:

http://www.example.com/path/test.php?test=2+2

<?php
$test = $_GET['test'];

echo $test;
?>

这打印出2 2

1 个答案:

答案 0 :(得分:4)

  • 被解释为URL中的空格。要使用+,您需要%2B

http://example.com/path/test.php?test=2%2B2

相关问题