PHP code example of visavi / captcha

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

    

visavi / captcha example snippets


header('Content-Type: image/gif');

$captcha = new CaptchaBuilder();
$_SESSION['captcha'] = $captcha->getPhrase();

return $captcha->render();

header('Content-Type: image/gif');

$phrase = new PhraseBuilder();
$phrase = $phrase->getPhrase(5, '1234567890');

$captcha = new CaptchaBuilder($phrase);
$captcha
    ->setWidth(150)
    ->setHeight(50)
    ->setTextColor(0, 0, 0)
    ->setBackgroundColor(255, 255, 255)
    ->setFont('/path-to-font')
    ->setWindowWidth(60)
    ->setPixelPerFrame(15)
    ->setDelayBetweenFrames(20);

$_SESSION['captcha'] = $captcha->getPhrase();

return $captcha->render();