note 37424 added to function.rand

From: Date: Fri, 14 Nov 2003 12:38:37 +0000
Subject: note 37424 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-60381@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37424 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37424&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37424&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60381) next »