ホームページ  >  記事  >  バックエンド開発  >  PHP番号動作確認コード

PHP番号動作確認コード

WBOY
WBOYオリジナル
2016-07-25 08:42:381059ブラウズ
  1. getValidate(100,30);
  2. 関数 getValidate($w,$h){
  3. $img = imagecreate($w,$h);
  4. $gray = imagecolorallocate($img,255,255,255);
  5. $black = imagecolorallocate($img,rand(0,200),rand(0,200),rand(0,200));
  6. $red = imagecolorallocate($img, 255, 0, 0);
  7. $white = imagecolorallocate($img, 255, 255, 255);
  8. $green = imagecolorallocate($img, 0, 255, 0);
  9. $blue = imagecolorallocate($img, 0, 0, 255);
  10. imagefilledrectangle($img, 0, 0, 100, 30, $black);
  11. for($i = 0;$i <80;$i++){
  12. imagesetpixel($img, rand(0,$w), rand(0,$h), $gray); $num1 = rand(1,99);
  13. $num2 = ランド(1,99);
  14. imagestring($img, 5, 5, rand(1,10), $num1, $red);
  15. imagestring($img,5,30,rand(1,10),getRand(), $white);
  16. imagestring($img,5,45,rand(1,10),$num2, $green);
  17. imagestring($img,5,65,rand(1,10),"=, $blue);
  18. imagestring($img,5,80,rand(1,10),"?", $red);
  19. header("content-type:image/png");
  20. imagepng($img);
  21. imagedestroy($img);
  22. }
  23. 関数 getRand(){
  24. $code = rand(0,1);
  25. switch ($code) {
  26. case 0:
  27. return "+";
  28. 休憩;
  29. ケース 1:
  30. "-" を返します。
  31. 休憩;
  32. デフォルト:
  33. # コード...
  34. ブレーク;
  35. }
  36. }
  37. ?>
  38. 复制代

验证コード、PHP
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。