PHP code example of zablose / captcha

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

    

zablose / captcha example snippets




ablose\Captcha\Captcha;
use Zablose\Captcha\Config;
use Zablose\Captcha\Image;

$captcha = new Captcha(
    new Image(
        (new Config())->update(['invert' => true, 'width' => 220])
    )
);

$data = [
    'captcha' => [
        'sensitive' => $captcha->isSensitive(),
        'hash' => $captcha->hash(),
    ],
];

// Add $data to the session.

echo $captcha->toPng();



    use Zablose\Captcha\Captcha;

    // ...

    Captcha::verify('captcha', 'hash');