Home  >  Article  >  Backend Development  >  php 自定义验证码函数的有关问题

php 自定义验证码函数的有关问题

WBOY
WBOYOriginal
2016-06-13 12:35:491099browse

php 自定义验证码函数的问题
请教各位一个问题:
php 自定义验证码函数
function random_text($count, $rm_similar = false)
{
    $chars = array_flip(array_merge(range(0, 9), range('A', 'Z')));
    if ($rm_similar)
    {
        unset($chars[0], $chars[1], $chars[2], $chars[5], $chars[8],
            $chars['B'], $chars['I'], $chars['O'], $chars['Q'],
            $chars['S'], $chars['U'], $chars['V'], $chars['Z']);
    }

    for ($i = 0, $text = ''; $i      {
        $text .= array_rand($chars);
    }
    return $text;
}
?>
这段代码是什么作用了,$chars[5]这些是啥意思:unset($chars[0], $chars[1], $chars[2], $chars[5], $chars[8],
            $chars['B'], $chars['I'], $chars['O'], $chars['Q'],
            $chars['S'], $chars['U'], $chars['V'], $chars['Z']);
这个函数调用的话,怎么调用了,给个例子。

php
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn