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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?