dongmeng1402 2010-05-05 12: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 13: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条)

报告相同问题?

悬赏问题

  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败