Home  >  Article  >  Backend Development  >  CI框架验证码CAPTCHA辅助函数用法实例_php实例

CI框架验证码CAPTCHA辅助函数用法实例_php实例

WBOY
WBOYOriginal
2016-06-07 17:15:38745browse

本文实例讲述了CI框架验证码CAPTCHA 辅助函数的用法,分享给大家供大家参考。具体如下:

使用CAPTCHA 辅助函数很方便生成验证码,但是图片是存储在文件夹下,不是输出流,感觉不够完美,可以拿来用用。

说明:产生4位的随机数,CI根目录下建立captcha文件夹。

复制代码 代码如下:
$this->load->helper('captcha');
$vals = array(
    'word' => rand(1000, 10000),
    'img_path' => './captcha/',
    'img_url' => 'http://localhost/ci/captcha/',
    //'font_path' => './path/to/fonts/texb.ttf',
    'img_width' => '150',
    'img_height' => 30,
    'expiration' => 7200
    );
$cap = create_captcha($vals);
echo $cap['image'];
?>

运行结果如下图所示:

希望本文所述对大家的CI框架程序设计有所帮助。

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