Php 致命错误:调用未定义的函数-codeigniter

Php 致命错误:调用未定义的函数-codeigniter,php,codeigniter,Php,Codeigniter,我得到这个错误,我不知道为什么 我有一个生成随机字符的函数 function randomString($length) { $len = $length; $base = 'ABCDEFGHIJKLMNOPQRSTWXYZabcdefghıjklmnoprstwxyz123456789'; $max = strlen($base) - 1; $activatecode = ''; mt_srand((double)

我得到这个错误,我不知道为什么

我有一个生成随机字符的函数

function randomString($length) {
        $len = $length;
        $base = 'ABCDEFGHIJKLMNOPQRSTWXYZabcdefghıjklmnoprstwxyz123456789';
        $max = strlen($base) - 1;
        $activatecode = '';
        mt_srand((double) microtime() * 1000000);
        while (strlen($activatecode) < $len + 1)
            $activatecode.=$base(mt_rand(0, $max));

        return activatecode;
    }
为什么我会犯这个错误? 看看这行:

$activatecode.=$base(mt_rand(0, $max)); // Your calling the string as a function
应该是:

$activatecode.=$base{mt_rand(0, $max)};

请看这一行:

$activatecode.=$base(mt_rand(0, $max)); // Your calling the string as a function
应该是:

$activatecode.=$base{mt_rand(0, $max)};

线路

$activatecode.=$base(mt_rand(0, $max));
调用其名称为
$base
=
'ABCDEFGHIJKLMNOPQRSTWXYZabcdefghıjklmnoprz13456789'内容的函数
,因此出现错误

线路

$activatecode.=$base(mt_rand(0, $max));

调用其名称为
$base
=
'ABCDEFGHIJKLMNOPQRSTWXYZabcdefghıjklmnoprz13456789'内容的函数
,因此出现错误

函数周围的
**
是什么?非常确定这会导致问题它是粗体函数,但在代码视图中不起作用:)Mert,您仍然需要返回
$activatecode
:-)为什么不直接使用
substr(md5(microtime()'somesalt')、0、10)
?是否需要使用md5来激活代码?函数周围的
**
是什么?非常确定这会导致问题它是粗体函数,但在代码视图中不起作用:)Mert,您仍然需要返回
$activatecode
:-)为什么不直接使用
substr(md5(microtime().'somesalt'),0,10)
?是否有必要使用md5来激活代码?顺便说一句,索引运算符是
[]
而不是
()
,您需要返回
$activatecode
(使用
$
)。顺便说一句,索引运算符是
[]
而不是
()
,您需要返回
$activatecode
(使用
$
)。PHP手册中的“注意:字符串也可以使用大括号访问,如$str{42},用于相同的目的。但是,从PHP5.3.0开始,此语法已被弃用。请改用方括号,如PHP手册中的$str[42]”“注意:出于同样的目的,字符串也可以使用大括号访问,如$str{42}。”。但是,从PHP5.3.0开始,这种语法就被弃用了。改用方括号,如$str[42]”