【发布时间】:2012-08-10 11:36:56
【问题描述】:
我想用 print 调试一个 php 生成的图像算法。 问题是它不输出我打印的文本。 我怎样才能输出变量,以便我可以调试? 谢谢, 富塔诺
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?";
}
【问题讨论】:
-
开启错误报告。您的脚本可能会在
print语句之前静默失败。尝试将print进一步向上移动代码,甚至移动到函数的开头,以确保它被调用。 -
脚本没有失败。我就是这样使用脚本 print '';
-
你现在看到了什么?考虑到您注释掉了对 header 函数的调用,但您仍在调用 imagepng,您应该会在它之后看到图像源和文本
-
我只看到图像并且在我把它放在 imagepng() 之后文本没有出现,如果我使用 imagejpeg() 代替它把文本放在右边 Oo
-
如果您看不到图像并且文本是您在代码中的某处发送图像标题。确保您没有在代码中的其他位置发送标题图像。