The read cache solution can be avoided only when the verification code is added with a time string

Source: Internet
Author: User
The read cache function can be avoided only when the verification code is added. this is an image verification function packaged in the class. However, I don't know where to add a time string to avoid reading the cache. PHPcode & lt ;? PhpclassImageCode {private $ randcode; the read cache can be avoided only when the verification code is added with a time string.
This is an image verification function I used in class packaging, but I don't know where to add a time string to avoid reading the cache.
PHP code
  
  Randcodelength = 5; $ this-> imgWidth = 80; $ this-> imgHeight = 20; $ this-> codelength = count ($ this-> code)-1; // Obtain the array length. the random range is $ this-> createrandcode (); $ this-> createimg (); $ this-> createString (); $ this-> drawline ($ this-> line); $ this-> ending ();} function createrandcode () {for ($ I = 0; $ I <$ this-> randcodelength; $ I ++) {// initialize the verification code $ this-> randcode. = $ this-> code [rand (0, $ this-> codelength)] ;}} function createimg (){/ /Create an image foreground background color $ this-> image = imagecreatetruecolor ($ this-> imgWidth, $ this-> imgHeight ); $ this-> background = imagecolorallocate ($ this-> image, 255,255,255, 0); $ this-> foreground = imagecolorallocate ($ this-> image );} function createString () {// create the string imagestring ($ this-> image, 5, rand (5, 35), 0, $ this-> randcode, $ this-> foreground );} function drawline ($ some) {for ($ I = 0; $ I <$ some; $ I ++) {imageline ($ this-> image, ra Nd (1, $ this-> imgWidth), rand (1, $ this-> imgHeight), rand (1, $ this-> imgWidth), rand (1, $ this-> imgHeight), $ this-> foreground) ;}} function ending () {ob_clean (); // discard the cache Content header ("Content-type: image/jpeg "); imagejpeg ($ this-> image) ;}}?>


------ Solution --------------------
Search for images on the Internet.
Script
Function RefreshCode (obj ){
Obj. src = obj. src + "? Code = "+ Math. random ();
}
Script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.