使辅助函数captcha,未提供word参数,是空字符,不是随机why?
$vals = array(//'word'=>'random',
'img_path' =>'./data/captcha/' ,
'img_url'=>base_url().'data/captcha/', );
$data=create_captcha($vals);
var_dump($data);如果不提供word制定参数,生成的不是随机字符,是个空字符。反之没有问题,跟文档描述有差距。
你的 CI 版本是? 本帖最后由 nenuwangd· 于 2016-12-5 16:51 编辑
Hex 发表于 2016-12-3 21:41
你的 CI 版本是?
上次谢谢你帮我回答问题。我用的ci版本是2.2.6。if (empty($word))
{
$word = '';
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$pool_length = strlen($pool);
$rand_max = $pool_length - 1;
// PHP7 or a suitable polyfill
if (function_exists('random_int'))
{
try
{
for ($i = 0; $i < $word_length; $i++)
{
$word .= $pool;
}
}
catch (Exception $e)
{
// This means fallback to the next possible
// alternative to random_int()
$word = '';
}
}
}
我看了下captcha_helper.php文件,里面没有定义$word_length,如果我直接给$word_length赋值,就会出错
看了一下,确实是 2.2 代码的一个 BUG,3.1.2 已经没有这个 BUG 了。
页:
[1]