|
class Verifycode extends Controller {
function Verifycode()
{
parent::Controller();
}
function index() {
session_start();
$verifyCode = getRandomCode();
$_SESSION["verifyCode"] = $verifyCode;
$imgWidth = $_REQUEST["width"];
$imgHeight = $_REQUEST["height"];
$imgFont = $_REQUEST["font"];
if($imgWidth == "") $imgWidth = 80;
if($imgHeight == "") $imgHeight = 20;
if($imgFont == "") $imgFont = 6;
doOutputImg($verifyCode, $imgWidth, $imgHeight, $imgFont);
}
//获取随机数字字符串
function getRandomCode($length=4) {
$glbVerifySeed = "123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";
$bgnIdx = 0;
$endIdx = strlen($glbVerifySeed)-1;
$code = "";
for($i=0; $i<$length; $i++) {
$curPos = rand($bgnIdx, $endIdx);
$code .= substr($glbVerifySeed, $curPos, 1);
}
return $code;
}
报错为:
Fatal error: Call to undefined function getrandomcode() in D:\xampp\htdocs\webgame\system\application\controllers\verifycode.php on line 23 |
|