0

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

ceejayoz
  • 171,474
  • 40
  • 284
  • 355
John55
  • 301
  • 2
  • 10
  • 6
    Possible duplicate of [How to encode the plus (+) symbol in URL](http://stackoverflow.com/questions/5450190/how-to-encode-the-plus-symbol-in-url) – kwarunek Jan 17 '16 at 16:24

1 Answers1

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

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

ceejayoz
  • 171,474
  • 40
  • 284
  • 355
Brian Riley
  • 863
  • 1
  • 7
  • 11