Home  >  Article  >  php教程  >  產生圖片隨機字串

產生圖片隨機字串

WBOY
WBOYOriginal
2016-06-13 12:35:02979browse

$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);  
?>

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 admin@php.cn
Previous article:function.inc.php超越phpNext article:source.php查看源文件