Before entering the topic, let's take a look at the following code, test.php
<?php$url = "Test2.php?name=". Base64_encode (' The string used to do the test '). " &age=23 "; Header (" Location: $url ");
test2.php
<?phpvar_dump (Base64_decode ($_get[' name '));d ie ();
When accessing http://localhost/test.php addresses, redirect to http://localhost/test2.php?name=55so5p2l5yga5rwl6k+v55qe5a2x56ym5liy& age=23 address, the browser outputs the result:
string ' To do the test? ' Y?? 9ke??)?., '(length=26)
What's going on, Base64_decode can't decode?
Careful observation of the redirected address after the encryption of the name parameter, which contains the "+" symbol, and the browser address bar encountered "+" symbol will be converted to a space, so to ensure that the correct decoding operation Base64_decode, we can first replace the space in the parameter Chengga number, As shown in the following code:
<?php$replaces = Array (' = = ' + '), Var_dump (Base64_decode (STRTR ($_get[' name '), $replaces)));d ie ();
Get the correct output result:
string ' The string used to do the test ' (length=27)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
PHP function Base64_encode After the argument contains the plus sign parsing error solution