PHP Verification code--image
Here we introduce the production of image verification code, the character verification code can refer to the following articles:
Click to open link
The production of the picture verification code is divided into three steps:
1. Make a picture library
2. Randomly select a picture
3. Output image Content
The code is as follows (here in order to facilitate my direct use of the local image, in fact there will be a lot of pictures, the path is stored in the database):
' Dog ', DirName (__file__). ' \pics\pic1.jpg ' = ' cat ', DirName (__file__). ' \pics\pic2.jpg ' = ' fish ', dirname (__file__). ' \pics\pic3.jpg ' = ' pig ', dirname (__file__). ' \pics\pic4.jpg ' = ' ma ', dirname (__file__). ' \pics\pic5.jpg ' = ' donkey ', DirName (__file__). ' \pics\pic6.jpg ' = ' bird ', dirname (__file__). ' \pics\pic7.jpg ' = ' chicken ', dirname (__file__). ' \pics\pic8.jpg ' = ' duck ', dirname (__file__). ' \pics\pic9.jpg ' + ' like ', ' $rnd = rand (0,9); $img = DirName (__file__). ' \pics\pic '. $rnd. jpg '; $_session[' authcode ') = $data [$img]; $content = file_get_contents ($img); Header ("Content-type : Image/png "); Echo $content;
Client:
Input error ';} Exit ();}? >
Result diagram:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.