<?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);
?>
我收到错误。
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ãÆ
答案 0 :(得分:3)
你的wordwrap.php文件不应该输出一个字节。但它在第33行打印出来的东西。您可以查看此行,看看发生了什么。
还要考虑使用bulit-in PHP函数wordwrap()而不是包含一些奇怪的代码。
所以,就这样:
<?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("\n",wordwrap($text,24,"\n"));
$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);
?>
答案 1 :(得分:2)
确保<?php
之前没有空格或回报。
此外,如果您的文件编码为UTF-8,请确保它没有BOM
答案 2 :(得分:0)