复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17class RandomCode{ private $str; public function __construct(){ $CodeArray = array_merge(range('A','Z'),range('a','z'),range('0','9'));//创建一个数组 列出A-Z a-z 0-9; shuffle($CodeArray);//将数组打乱 foreach(array_rand($CodeArray,6)as $keys){ $this->str .= $CodeArray[$keys];//返回随机 } } public function GetRandStr(){ return $this->str; } }
测试
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14<?php require_once 'Tools.inc.php'; $i = new RandomCode(); $im = @imagecreate(70, 32); imagecolorallocate($im, 100, 255, 255); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 25,5, 5, $i->GetRandStr(), $text_color); ob_clean(); header("Content-type: image/png"); imagepng($im); imagedestroy($im); ?>
没有技术含量 喜欢的朋友拿去 高手当看笑话 我就当积累代码吧
最后
以上就是虚幻小蝴蝶最近收集整理的关于PHP下生成随机码的全部内容,更多相关PHP下生成随机码内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复