base64_encode

(PHP 4, PHP 5, PHP 7, PHP 8)

base64_encode使用 MIME base64 对数据进行编码

说明

base64_encode(string $string): string

使用 base64 对 string 进行编码。

设计此种编码是为了使二进制数据可以通过非纯 8-bit 的传输层传输,例如电子邮件的主体。

Base64-encoded 数据要比原始数据多占用 33% 左右的空间。

参数

string

要编码的数据。

返回值

编码后的字符串数据。

范例

示例 #1 base64_encode() 示例

<?php
$str
= 'This is an encoded string';
echo
base64_encode($str);
?>

以上例程会输出:

VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top