我如何用打印调试PHP图像? [英] how do i debug PHP Image with print?
问题描述
我想用print调试php生成的图像算法。
问题是它不会输出我打印的文本。
如何输出变量,以便我可以调试?
谢谢,
Furtano
i want to debug an php generated image algorithm with print. The problem is that it doesn't output the text i put in print. How can i output variables, so that i can debug? Thanks, Furtano
public function drawPicture()
{
$im = imagecolorallocate ($this->picture, 255, 0, 255);
imagettftext($this->picture, $this->fontSize , 0, 100, 100,$im , "cooperm.TTF", $this->name);
# int ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
//imagecopy($this->picture, $this->pika, $this->wappen['pika']['dst_x'], $this->wappen['pika']['dst_y'], 0, 0, $this->pika_size[0], $this->pika_size[1]);
$zufall = rand(1,99999999);
#header("Content-Type: image/jpeg");
imagepng($this->picture);
$this->checkFontSize();
imagedestroy($this->picture);
print "WHY_DOESNT_PRINT?";
}
推荐答案
您正在向浏览器发送.png图像,因此浏览器会尝试显示图像。附加文本仅被视为无效图像数据,因此无法显示。
You are sending a .png image to the browser, so the browser tries to display an image. The additional text is just seen as invalid image data and thus not displayed.
您的问题的解决方案是使用 header()
调用将调试消息发送到您的浏览器,或使用Firefox + Firebug + PHP firebug适配器。 Firebug使用标头来传输信息,因此它在图像生成功能中是安全的。
A solution to your problem would be using header()
calls to send debug messages to your browser, or use Firefox+Firebug+ a PHP firebug adapter. Firebug works with headers to transmit information, so it's safe in image generation functions.
这篇关于我如何用打印调试PHP图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!