0

First of all thanks in advance to everyone helping me out with my question.

I've got a base64_encoded string that looks like:

$_GET['val']='8AH1Oc+gqwjMPyyAL+PIu2neFF5C+bQAkDf/FJdApT4AC09jD/o9I3vHs0cIPC8678TzuFMVlZd+7zA/fV1b9OEF0Uwnao3aURtGUkbx4NoEQFvQ1hBPy0EbUobbRQO/WojW9F6oowS/yX+I+qj53N4nORxhKJRDzMIQO1W8sOSH1BkBHsCotG1dj813OWLoBLy+K9ABLBqUta9+0Mk3JCg+wO/WA2Bh06M0n4ux+qk=';

but when im trying to get the same variable to decode it i recieve it with pluses removed:

$string=$_GET['val'];
echo $string; // either echo $_GET['val']; output will be '8AH1Oc gqwjMPyyAL PIu2neFF5C bQAkDf/FJdApT4AC09jD/o9I3vHs0cIPC8678TzuFMVlZd 7zA/fV1b9OEF0Uwnao3aURtGUkbx4NoEQFvQ1hBPy0EbUobbRQO/WojW9F6oowS/yX I qj53N4nORxhKJRDzMIQO1W8sOSH1BkBHsCotG1dj813OWLoBLy K9ABLBqUta9 0Mk3JCg wO/WA2Bh06M0n4ux qk='

Could somebody please explain why does it happen?

  • 3
    `+` in a URL is the way spaces are encoded. Whoever is sending the URL needs to encode it properly. In PHP they should use `urlencode()`, in JavaScript it's `encodeURIComponent()`. – Barmar Jan 25 '20 at 11:09
  • 1
    You have to remember that `$_GET` is automatically passed through `urldecode()` in PHP. Also, dots and spaces in `$_GET` are automatically converted to underscores. See [`$_GET`](http://php.net/$_GET). – Sherif Jan 25 '20 at 11:15

0 Answers0