PHP learning Base64_encode + # variable Space

Source: Internet
Author: User

In the base64 encoding decoding when the + number in the HTML by the background Php->get reading will be automatically replaced with a space, causing garbled problems

It's not an echo display error, but an objective reality.

Reason excerpt: http://blog.csdn.net/wang0928007/article/details/7429568

The plus sign (+) is part of the BASE64 encoding, and the plus sign is considered a space in querystring.    Therefore, when a string containing a BASE64 encoding is directly part of the URL, if it contains a plus sign, an error will occur when using QueryString to read, and then use BASE64 decoding.  There are two solutions: one is to use the BASE64 string as part of the URL, encode using a function of the UrlEncode class, and then, after receiving the BASE64 string, use ReplaceAll to replace the space in the string with the Chengga number and then decode it. "

// solve the problem of changing the base64 into a space during transcoding $key Str_replace (', ' + ',$this->input->get (' key ')); $key Base64_decode ($key);        

The procedure uses the direct substitution, but cannot avoid the other symbol to appear the error, at present appears only the + number will be wrong? Pending troubleshooting

PHP learning Base64_encode + # variable Space

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.