dongyao5186 2012-05-17 18:37
浏览 189
已采纳

为什么echo()输出的base64_decode()无法在浏览器中完全显示?

please see the code below :

<?php
$str = 'PD9waHANCiRzdHJpbmcgPSAiYmVhdXRpZnVsIjsNCiR0aW1lID0gIndpbnRlciI7DQoNCiRzdHIg
PSAnVGhpcyBpcyBhICRzdHJpbmcgJHRpbWUgbW9ybmluZyEnOw0KZWNobyAkc3RyLiAiPGJyIC8+
IjsNCg0KZXZhbCgiXCRzdHIgPSBcIiRzdHJcIjsiKTsNCmVjaG8gJHN0cjsNCj8+IA==';
echo base64_decode($str);
?>

this is a simple php code and you can decode base64 string by using the URL below :
http://www.base64decode.org/

why base64_decode() function in this example can not do it's job. the output is like below :

"; eval("\$str = \"$str\";"); echo $str; ?>  

instead of :

<?php
$string = "beautiful";
$time = "winter";

$str = 'This is a $string $time morning!';
echo $str. "<br />";

eval("\$str = \"$str\";");
echo $str;
?> 

what is the problem and how can i fix it for big codes?

EDIT :
there is an invisible part of output and i can find it by page source.
but why do we have this reaction?
thanks in advance

  • 写回答

4条回答 默认 最新

  • duanliujie8639 2012-05-17 18:39
    关注

    The problem is that you're viewing it as HTML. If you look at the source or pass a header to make the browser interpret it as text, you'll see the whole thing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b