无法修改标题信息 - 标题已发送
<?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ãÆ
您的wordwrap.php文件不应该输出一个字节。但它在第33行中列印了一些东西。你可以检查这一行,看看发生了什么。
也考虑使用内置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);
?>
24) \t { \t \t $海峡= SUBSTR($件[$ i]于,0,24); $ str =“。”substr($ pieces [$ i],24,strlen(str)); \t \t \t } \t \t 其他 \t { \t \t如果(strlen的($件[$ i]于)> $ spaceleft) \t \t \t { \t \t \t $ spaceleft = 24; \t \t \t $ text = $ text。“:”。$件[$ i]于; \t \t \t} \t \t别的 \t \t { \t \t \t $ spaceleft = $ spaceleft-(strlen的($件[$ i]于)+ 1); \t \t \t $ text = $ text。$ pieces [$ i]。“”; \t \t} \t} \t } $ p = explode(“:”,$ text); return $ p; } ?> – goblin2986 2010-05-05 13:38:18
这是我的wordwrap功能。 – goblin2986 2010-05-05 13:39:05
@bhaskaragr我在这里看不到第33行。但是根本不要使用它。使用我添加的代码 – 2010-05-05 13:43:03
哪条线上面说的错误是吗? – 2010-05-05 12:12:39
请学会复制整个错误信息,而不是它的一部分。你也可以阅读它 - 这是非常清楚的 – 2010-05-05 12:12:53