PHP code example of barrett / captcha

1. Go to this page and download the library: Download barrett/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/ */

    

barrett / captcha example snippets


$Captcha = new barrett\Captcha(['setZh'=>true,'length'=>4]);

$Captcha = new barrett\Captcha();
return $Captcha->createImg('user');

$Captcha = new barrett\Captcha();
//createNum方法会返回被创建的验证码
$code = $Captcha->createNum('user');
//使用短信发送数字验证码
$Sms->sendToPhone($code['data]);

$Captcha = new barrett\Captcha();
return $Captcha->check($_POST,'user');

$old = $Captcha->createNum('old');

$new = $Captcha->createNum('new');