The source code is as follows:
1<?PHP2 //Image Verification Code3 //The method must be at the top of the script4 Session_Start();5 //the correspondence between the verification code picture and the corresponding validation value6 $table=Array(7' Pic0 ' = ' bo ',8' Pic1 ' = ' hamster ',9' Pic2 ' = ' satsuma ',Ten' pic3 ' = ' Teddy ', One ); A - $index=Rand(0,3); - the $value=$table[' pic '.$index]; - //verification values for random CAPTCHA images - $_session[' authcode '] =$value; - + //the address of the Verification code picture - $filename=dirname(_file_). ' \\pic '.$index.‘. jpg; + $contents=file_get_contents($filename); A at //The first picture does not display, displays a bunch of garbled characters, plus this sentence is good! - Ob_clean(); - - Header(' Content-type:image/jpeg '); - Echo $contents; - in?>
Check the document, it said, but I still do not know what it is talking about!
void
ob_clean ( void )
This function is used to discard the contents of the output buffer.
This function does not destroy the output buffer, and the Ob_end_clean () function destroys the output buffer.
"Problem" to do the picture verification code garbled, in front of the header with Ob_clean () can be magical display?!