首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何生成Codeigniter-2 captcha作为有意义的单词而不是代码?

如何生成Codeigniter-2 captcha作为有意义的单词而不是代码?
EN

Stack Overflow用户
提问于 2015-06-29 03:51:35
回答 1查看 555关注 0票数 3

我知道,在默认情况下,编码点火器-2可以生成字母数字类型的captcha。如何将其扩展为生成有意义的单词

例如:

  1. morning
  2. overlooking
  3. 等。

生成captcha的代码示例:

代码语言:javascript
复制
$vals = array(
                'img_path'      => './assets/captcha/',
                'img_url'       => 'http://url/assets/captcha/',
                'img_width'     => '130',
                'font_path'     => './assets/fonts/Moms_typewriter.ttf',
                'img_height'    => '33',
                'expiration'    => CAPTCHA_MAX_TIME_EXPIRATION
                );

$cap = create_captcha($vals);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-29 04:19:34

只需在循环中使用array和pass元素

代码语言:javascript
复制
<?php

    $ab = array('Morning','Night','welcome','im here');

    $word = '';
    $n = 0;
    while ($n < 1)
    {
        $word .= $ab[mt_rand(0,9)];
        $n++;
    }


    $vals = array(
        'word'          => $word,
        'img_path'      => './assets/captcha/',
        'img_url'       => base_url().'assets/captcha/',
        'img_width'     => '130',
        'font_path'     => './assets/fonts/Moms_typewriter.ttf',
        'img_height'    => '33',
        'expiration'    => CAPTCHA_MAX_TIME_EXPIRATION
    );
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31107502

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档