简体   繁体   中英

how do i debug PHP Image with print?

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?";


    }

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.

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.

To debug using rorrorlog the point that the script that you want to see. The written files can be easily viewable.

Es:

error_log("\r\n debug " . implode("; ", $hc), 3, "errors.log"); // in case array
error_log("\r\n print " . $im, 3, "errors.log");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM