PHP 解码 Base64 编码
作者:远山有雾青石小巷
时间:2024-02-27
浏览:0
PHPbase64_decode函数将字符串转换为长纯文本,然后与用户定义值集的主函数一起发送。base64_decode()是php的内置函数,最常用于网络上的邮件功能。函数语法:stringbase64_decode($string,$strict)它需要两个参数。$string-用于存储编码数据,是必须的。$strict-虽然此参数不像前者那样是强制性的,但当它设置为TRUE,时,base64_decode将返回FALSE,前提是它的输入包含函数字母表以外的数据。否则,无效数据将被自动丢弃。返回值:
PHP base64_decode 函数将字符串转换为长纯文本,然后与用户定义值集的主函数一起发送。
base64_decode() 是 php 的内置函数,最常用于网络上的邮件功能。
函数语法:
string base64_decode( $string, $strict)
它需要两个参数。
$string- 用于存储编码数据,是必须的。$strict- 虽然此参数不像前者那样是强制性的,但当它设置为TRUE,时,base64_decode 将返回FALSE,前提是它的输入包含函数字母表以外的数据。否则,无效数据将被自动丢弃。
返回值:
base64 解码函数在失败的情况下返回 FALSE,并可能返回二进制值。
PHP Base64_decode 函数示例代码 1
php
$string = base64_encode ('Your string values are encoded');
echo "1.Here is the encoded function value in a Machine readable fORMat = ".$string ."
";
echo "2.The function decodes the formerly encoded string value" ."
" .base64_decode($string);
?>
输出:
1.Here is the encoded function value in a machine readable
format = WW91ciBzdHJpbmcgdmFsdWVzIGFyZSBlbmNvZGVk
2. The function decodes the formerly encoded string value
Your string values are encoded.
示例代码显示了 base64_decode() 函数如何在一个简单的场景中工作。
为了对编码数据进行解码,程序为变量赋值,然后与解码函数一起使用。
而输出表明 base64_decode() 如何将数据转换回用户可读格式。
PHP Base64_decode 函数示例代码 2
php
//The following variable is assigned with a string set
$string = "HELLO--こんにちは--你好";
//string contains bilingual text
//base64 is used to encode the data first into the $enco variable
$enco = base64_encode ($string);
//finally the base64_decode functionis used to decode the encoded value
$deco = base64_decode ($enco);
echo $deco;
?>
输出:
HELLO--こんにちは--你好
作者最新文章
iphone电池不耐用怎么修复?实用方法教程
2026-09-22 15:16
2026年车市新势力崛起:新车型精准发力 单月销量突破两万大关
2026-08-25 15:36
黄渤亮相重庆赛力斯工厂 共庆全新一代问界M9全国首批用户交付盛典
2026-08-25 15:35
iPhone14Pro怎么关闭待机显示 iPhone14Pro关闭待机显示教程
2026-08-25 14:21
荣耀 X80 Pro Max 手机获 SGS 五星抗摔认证 并推出免费换屏服务
2026-08-25 11:41
热门文章
更多
精品专题
更多
Mac软件
更多
WINDOWS
更多


































