Home  >  Article  >  Backend Development  >  简单中文验证码

简单中文验证码

WBOY
WBOYOriginal
2016-07-25 08:48:56990browse
简单中文验证码
  1. $text = '的一是不了人我在有他这中大来上国个到说们为子和你地出道也时年得就那要下以生会自着去之过家学对可她里后小么心多天而能好都然没日于起还发成事只作当想看文无开手十用主行方又如前所本见经头面公同三已老从动两长知民样现分将外但身些与高意进把法此实回二理美点月明其种声全工己话儿者向情部正名定女问力机给等几很业最间新什打便位因重被走电四第门相次东政海口使教西再平真听世气信北少关并内加化由却代军产入先山五太水万市眼体别处总才场师书比住员九笑性通目华报立马命张活难神数件安表原车白应路期叫死常提感金何更反合放做系计或司利受光王果亲界及今京务制解各任至清物台象记边共风战干接它许八特觉望直服毛林题建南度统色字请交爱让';
  2. $im = imagecreatetruecolor(100,45);
  3. $font = './msyhbd.ttf';
  4. $len = mb_strlen($text,'UTF-8');
  5. $grey = imagecolorallocate($im,200,200,200);
  6. imagefill($im,0,0,$grey);
  7. for($i = 0,$x = 0 ;$i $color = imagecolorallocate($im,mt_rand(0,190),mt_rand(0,190),mt_rand(0,190));
  8. $x += $i*10 + mt_rand(1,5);
  9. $tmp = mb_substr($text,mt_rand(0,$len),1,'UTF-8');
  10. imagettftext($im,mt_rand(10,16),mt_rand(-15,15),$x,mt_rand(21,25),$color,$font,$tmp);
  11. }
  12. header('content-type:image/png');
  13. imagepng($im);
  14. imagedestroy($im);
  15. ?>
复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]