URL losing plus sign

2020-02-07 11:52发布

问题:

I realize that in a URL, the + symbol represents a space, however I need to keep the plus sign. How can I do this? My URL and code are as follows:

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

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

echo $test;
?>

This prints out 2 2

回答1:

  • is intepreted as a space in a URL. To use a + you need %2B.

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



标签: php url