Home Tutorial Php Phpgd PHP gd caching an image

 
 

PHP gd caching an image
Posted on: November 2, 2009 at 12:00 AM
This example shows how to display caching of an image.

<?php

header("Content-type: image/png");

$filename = date("Y_m_d").".png";

if (is_file($filename)) {

readfile($filename);

exit;

}

$image = imagecreatetruecolor(100,25);

$white = imagecolorallocate($image,255,255,255);

$black = imagecolorallocate($image,0,0,0);

imagefill($image,0,0,$white);

imagerectangle($image,0,0,99,24,$black);

imagestring($image,5,5,5,date("d/m/Y"),$black);

imagepng($image,$filename);

imagepng($image);

imagedestroy($image);

?>

After running the program you will get the following output

Related Tags for PHP gd caching an image:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.