PHP code example of deschamps-jeremy / php-captcha

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

    

deschamps-jeremy / php-captcha example snippets


composer 

var_dump([
    0 => CaptchaService::get(),
    1 => CaptchaService::get(),
]);

array(2) {
    [0]=> array(2) {
        ["token"]=> string(28) "20201011111830_5f7ec344d119e"
        ["base64"]=> //A JPG image on base64 string
    },
    [1]=> array(2) {
        ["token"]=> string(28) "20201011111830_5f7ec344d2580"
        ["base64"]=> //A JPG image on base64 string
    }
}

var_dump([
    0 => CaptchaService::isValid("20201011111830_5f7ec344d119e", "good response"),
    1 => CaptchaService::isValid("20201011111830_5f7ec344d119e", "good response"),
    2 => CaptchaService::isValid("20201011111830_5f7ec344d2580", "bad response"),
]);

array(2) {
    [0]=> bool(true)
    [1]=> bool(false)
    [2]=> bool(false)
}