PHP code example of aetiom / voight-kampff

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

    

aetiom / voight-kampff example snippets


$pool = array(
    array(
        'idStr' => '0120',
        'lang'   => array(
            'en' => 'table',
            'fr' => 'table'
        )
    ),
    array(
        'idStr' => '2501',
        'lang'   => array(
            'en' => 'glass',
            'fr' => 'verre'
        )
    ),
    
    ...
    
    array(
        'idStr' => '3241',
        'lang'   => array(
            'en' => 'book',
            'fr' => 'livre'
        )
    )
);

$captcha = new VoightKampff\Captcha('captcha_identifier_in_string', $pool);

$count = $captcha->getOptions()->imageCount;
$prefix = $captcha->getOptions()->cbPrefix;

$answers = \VoightKampff\Captcha::obtainPostedImages($count, $prefix);
$captcha->verify($answers);

$images = $captcha->getImages();
$directive = $captcha->getDirective($lang);
$error = '';

if ($captcha->getError() !== null) {
    $error = $captcha->getError()->fetch($lang);
}

$render = new \VoightKampff\Render($captcha->getOptions(), $images);
$htmlCode = $render->createHtml($directive, $error);