controller同一文件不同function的调用出错
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 functiongetrandomcode() in D:\xampp\htdocs\webgame\system\application\controllers\verifycode.php on line 23 应该这样调用:
$verifyCode = $this->getRandomCode(); 感叹某些朋友在用了框架以后,把 PHP 基础知识和面向对象的基础知识都忘了。。。。。
希望不要把框架看成是火星来客,他就是普通的 PHP 程序。 {:3_53:}
呵呵,基础很重要 是啊,要习惯CI的语法,不过我蛮喜欢这个格式的, ->->->->感觉很high 像这样的问题自己不思考一下就贴来让大伙帮忙,作者应该反思一下。不然永远原地踏步
页:
[1]