Home  >  Article  >  Backend Development  >  php base64_decode and base64_encode_PHP tutorial

php base64_decode and base64_encode_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:01:054249browse

php base64_decode and base64_encode ​

base64_decode
(PHP 4, PHP 5)

base64_decode - Base64 encoded MIME of decoded data

Description
string base64_decode (string $data[, boolean $strict=false])
Decode a BASE64 encoded data.

Parameters

Data
Encode data.

Strict
Returns FALSE if the input contains characters outside of a base64 alphabet.


Return value
Returns raw data or FALSE on failure. The data returned may be binary.

Modify

Release Notes
5.2.0 Strict Supplement


Example

Example #1 Example of base64_decode()

$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';
echo base64_decode($str);
?>
The above example will output:

This is an encoded string

base64_encode
(PHP 4, PHP 5)

base64_encode - Base64 using MIME encoded data

Description
String base64_encode (String $data)
Encode specific data to Base64.

This encoding is intended to enable binary data to survive transport through transport layers that do not support 8-bit encoding, such as email agencies.

Base64-encoded data takes approximately 33% more space than the original data.

Parameters

Data
The data are coded.


Return value
Encoded data, as a string.

Example

Example #1 base64_encode() example

$str = 'This is an encoded string';
echo base64_encode($str);
?>
The above example will output:

VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445458.htmlTechArticlephp base64_decode and base64_encode base64_decode (PHP 4, PHP 5) base64_decode - Base64 encoded MIME description of decoded data string base64_decode (string $data[, cloth...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn