PHP 開発検証コード 文字と数字が混在した検証コード

文字と数字の混合確認コード

確認コードのコンテンツ表示に文字と数字を混合して表示します

<?php
 $image = imagecreatetruecolor(100,30);
 $bgcolor = imagecolorallocate($image,255,255,255);//#FFFFFFFFFFFF
 imagefill($image,0,0,$bgcolor);
 for ($i=0;$i<4;$i++){
     $fontsize = 6;
     $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120));
     $data='abcdefghijklmnopqrstuvwxyz1234567890';
     $fontcontent=substr($data,rand(0,strlen($data)),1);
     $x = ($i * 100/4)+rand(5,10);
     $y = rand(5,10);
     imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);
 }
 for($i=0;$i<200;$i++){
     $pointcolor = imagecolorallocate($image,rand(50,200),rand(50,200),rand(50,200));
     imagesetpixel($image,rand(1,99),rand(1,29),$pointcolor);
 }
 for($i=0;$i<8;$i++){
     $linecolor = imagecolorallocate($image,rand(60,220),rand(60,220),rand(60,220));
     imageline($image,rand(1,99),rand(1,29),rand(1,99),rand(1,29),$linecolor);
 }
 header('content-type: image/png');
 imagepng($image);
 //销毁
 imagedestroy($image);
 ?>

確認コードに文字と数字の違いはあまりなく、生成された数字を文字と数字に変更するだけです

for ($i=0;$i<4;$i++){
     $fontsize = 6;
     $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120));
     $data='abcdefghijklmnopqrstuvwxyz1234567890';
     $fontcontent=substr($data,rand(0,strlen($data)),1);
     $x = ($i * 100/4)+rand(5,10);
     $y = rand(5,10);
     imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);
 }

違いは $data='abcdefghijklmnopqrstuvwxyz1234567890'; 辞書を定義します

$fontcontent 関数を定義し、辞書内の数値をインターセプトしてすぐに表示します。


学び続ける
||
<?php $image = imagecreatetruecolor(100,30); $bgcolor = imagecolorallocate($image,255,255,255);//#FFFFFFFFFFFF imagefill($image,0,0,$bgcolor); for ($i=0;$i<4;$i++){ $fontsize = 6; $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120)); $data='abcdefghijklmnopqrstuvwxyz1234567890'; $fontcontent=substr($data,rand(0,strlen($data)),1); $x = ($i * 100/4)+rand(5,10); $y = rand(5,10); imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor); } for($i=0;$i<200;$i++){ $pointcolor = imagecolorallocate($image,rand(50,200),rand(50,200),rand(50,200)); imagesetpixel($image,rand(1,99),rand(1,29),$pointcolor); } for($i=0;$i<8;$i++){ $linecolor = imagecolorallocate($image,rand(60,220),rand(60,220),rand(60,220)); imageline($image,rand(1,99),rand(1,29),rand(1,99),rand(1,29),$linecolor); } header('content-type: image/png'); imagepng($image); //销毁 imagedestroy($image); ?>
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!