dongmeng1402 2010-05-05 04:10
浏览 67
已采纳

无法修改标头信息 - 已由[重复]发送的标头

This question already has an answer here:

<?php 

require_once 'wordwrap.php';
$text="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum";
$im=imagecreatefrompng('testing.png');
$arr=word($text);
$white = imagecolorallocate($im,255,255,255);
$grey = imagecolorallocate($im, 128, 128, 128);
$font='arial.ttf';
$m=121;
for($i=0;$i<sizeof($arr);$i++)
{

    //imagettftext($im,12,0,11,$m+$t,$grey,$font,$arr[$i]);
//echo $arr[$i]."<br/>";

}
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

I am getting error.

Warning: Cannot modify header information - headers already sent by (output started at /home2/puneetbh/public_html/prideapp/Testing/wordwrap.php:33) in /home2/puneetbh/public_html/prideapp/Testing/checkimage.php on line 16
‰PNG  ��� IHDR�� ��ô���J"Þ/�� �IDATxœì¼KvÉŽ%ŠŸ}Ü)EfäjÕxÝËÇ›nE^)Èãn?�Õ€J‘UÕ~ß --ŠKä>ƒÛàÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ
</div>
  • 写回答

3条回答 默认 最新

  • dongli564510 2010-05-05 05:31
    关注

    your wordwrap.php file should not output a byte. But it prints something out in the 33th line. You can check this line and see what happened.

    Also consider to use bulit-in PHP function wordwrap() instead of including some strange code.

    So, make it like this:

    <?php 
    
    #require_once 'wordwrap.php';
    $text="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum";
    $im=imagecreatefrompng('testing.png');
    $arr=explode("
    ",wordwrap($text,24,"
    "));
    $white = imagecolorallocate($im,255,255,255);
    $grey = imagecolorallocate($im, 128, 128, 128);
    $font='arial.ttf';
    $m=121;
    for($i=0;$i<sizeof($arr);$i++)
    {
    
        //imagettftext($im,12,0,11,$m+$t,$grey,$font,$arr[$i]);
    //echo $arr[$i]."<br/>";
    
    }
    header('Content-type: image/png');
    imagepng($im);
    imagedestroy($im);
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部