note 37424 deleted from function.rand by aidan
| From: | aidan@php.net | Date: | Sat, 11 Sep 2004 07:40:16 +0000 |
| Subject: | note 37424 deleted from function.rand by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76448@lists.php.net to get a copy of this message | ||
Note Submitter: jordan at do not spam .com
----
You can prevent image caching with the following code:
// Begin image.php
<?php
$rand1 = rand(500,20000);
$rand2 = rand(500,20000);
$rand3 = rand(500,20000);
$rand4 = rand(500,20000);
$rand5 = rand(500,20000);
$md1 = md5($rand1.$rand2);
$md2 = md5($rand3.$rand4.$rand5);
$rq = $md1.$md2;
print("<img src=\"".$path."?".$rq."\">");
?>
// End image.php
Usage would be: <img src="image.php?path=images/head.gif">
It would generate something like this: <img src="images/head.gif?2b05948daaa502d7d97fd0503cd
c4b3d24100ff053f153046cc36f6281d08cb5">
This can be useful if you frequently update images. It prevents the browser from loading the cached
version.