- <?php
- class CheckCode
- {
- private $codenum;
- public function __construct($codenum)
- {
- $this->codenum = $codenum;
- }
- public function checkauthCode()
- {
- $a = "";
- for ($i=0;$i<$this->codenum;$i++)
- {
- $x = rand(0,2);
- switch($x)
- {
- case 0:
- $r = rand(48,57);
- break;
- case 1:
- $r = rand(65,90);
- break;
- case 2:
- $r = rand(97,122);
- break;
- }
- $y = sprintf("%c",$r);
- $a.=$y;
- }
- return $a;
- }
- }
- $p = new CheckCode(10);
- echo $p->checkauthCode();
- ?>