ホームページ  >  記事  >  バックエンド開発  >  画像からランダムな文字列を生成する_PHP チュートリアル

画像からランダムな文字列を生成する_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-21 15:58:44949ブラウズ

$base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';  
$words = 5;  
$rand_top = strlen($base) - 1;  
$string = '';  
header("Content-type: image/png");  
$im = imagecreate($words*16, $words*5);  
$black = imagecolorallocate($im, 90, 60, 120);  
$white = imagecolorallocate($im, 255, 255, 255);  
for($i=0;$i $idx = mt_rand(0, $rand_top);  
imagestring($im, 3, $i*15+2, mt_rand(0, $words*2), $base[$idx], $white);  
}
imagepng($im);  
imagedestroy($im);  
?>

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/317488.html技術記事 ?php $base='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; $words=5; $rand_top=strlen($base)-1; $string=''; header("コンテンツタイプ:画像/png"); $im=imagecreate($word...
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。