PHP code example of rain_sunshine_cloud / php_captcha

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

    

rain_sunshine_cloud / php_captcha example snippets


    /**
     * 存储验证码
     * @param  string $key [存储使用的键]
     * @param  string $text [验证码]
     * @return [bool]       
     */
    protected abstract  function storeText(string $key,string $text);

    /**
     * 获取存储的字符串
     * @param  string $key [存储使用的键]
     * @return [string]    存储的验证码
     */
    protected abstract  function getStoreText(string $key);

    /**
     * 删除存储的字符串
     * @param  string $key [存储使用的键]
     * @return [bool]
     */
    protected abstract function deleteStoreText(string $key);


$res->create('sjfdh'); //生成验证码图像 ,
$res->create('./file/img.png'); //将生成的验证码存储在某个文件内,只支持保存为png;
$res->verify('sdfkj','key'); //验证码验证,不区分大小写,存储使用的键为key
$res->verify('sjdfjk','key',true); //验证码验证,区分大小写,存储使用的键为key