词条 | base64_decode |
释义 | 函数说明base64_decode (PHP 4, PHP 5) base64_decode — 对使用 MIME base64 编码的数据进行解码 函数定义string base64_decode ( string $encoded_data ) base64_decode() 对 encoded_data 进行解码,返回原始数据,失败则返回 FALSE。返回的数据可能是二进制的。 实例说明例-1使用base64_decode()函数对简单字符串进行解码。 <?php $str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='; echo base64_decode($str); ?> 此示例将显示: This is an encoded string 例-2使用base64_encode()函数和base64_decode()函数对迅雷和FlashGet、QQ旋风地址进行互相转化。 <?php $txt1=trim($_POST['text1']); $txt2=trim($_POST['text2']); $txt3=trim($_POST['text3']); $button=$_POST['button']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <title>迅雷和FlashGet,QQ旋风地址 地址转换工具</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta content="迅雷,FlashGet,地址转换," name="keywords"> </head> <body> <form name="form1" method="post" action=""> <hr size="1"> <h3>迅雷转换</h3> <P>转换地址: <input name="text1" value="<?php echo $txt1;?>" type="text" style="width:516px;" /></P> <P>转换后的: <input type="text" value="<?php if($button=="普通地址->迅雷地址") echo "thunder://".base64_encode("AA".$txt1."ZZ"); if($button=="迅雷地址->普通地址") echo substr(base64_decode(str_ireplace("thunder://","",$txt1)),2,-2); ?>" style="width:516px;" /></P> <P> <input type="submit" name="button" value="普通地址->迅雷地址" /> <input type="submit" name="button" value="迅雷地址->普通地址" /></P> <h3>FlashGet转换</h3> <P>FlashGet地址: <input name="text2" value="<?php echo $txt2;?>" type="text" style="width:516px;" /></P> <P>转换后 地址: <input type="text" value="<?php if($button=="普通地址->FlashGet地址"){ $txt2 ="[FLASHGET]".$txt2.'[FLASHGET]'; echo "flashget://".base64_encode($txt2); } if($button=="FlashGet地址->普通地址") echo str_ireplace("[FLASHGET]","",base64_decode(str_ireplace("flashget://","",$txt2))); ?>" style="width:516px;" /></P> <P> <input type="submit" value="普通地址->FlashGet地址" name="button" /> <input type="submit" value="FlashGet地址->普通地址" name="button" /></P> <h3>QQ旋风转换</h3> <P>QQ旋风地址: <input name="text3" value="<?php echo $txt3;?>" type="text" style="width:516px;" /></P> <P>转换后 地址: <input type="text" value="<?php if($button=="普通地址->QQ旋风") echo "qqdl://".base64_encode($txt3); if($button=="QQ旋风->普通地址") echo base64_decode(str_ireplace("qqdl://","",$txt3)); ?>" style="width:516px;" /></P> <P> <input type="submit" value="普通地址->QQ旋风" name="button" /> <input type="submit" value="QQ旋风->普通地址" name="button" /></P> </form> </body> </html> |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。