PHP code example of zyan / captcha

1. Go to this page and download the library: Download zyan/captcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zyan / captcha example snippets


use Zyan\Captcha\Captcha;

$config = [
    'width' => 108, //宽度
    'height' => 38, //高度
    'background' => '#eee', //底色
    'font_size' => 20, //字体大小
    'session' => true //使用sessoin保存及验证
];

$captcha = Captcha::make($config); //$cofnig 为可选,默认为上参数

$captcha->save($filename);

$captcha->getCode();

$captcha->verify($code); //如通过验证,会清除session