PHP code example of vaibhavpandeyvpz / ank

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

    

vaibhavpandeyvpz / ank example snippets




/**
 * @desc Create an instance of desired captcha generator. Ank\CaptchaGenerator will generate a random captcha code
 *      while Ank\MathCaptchaGenerator will generate basic mathematics calculations for user to solve.
 */
$captcha = new Ank\CaptchaGenerator();
// or
$captcha = new Ank\MathCaptchaGenerator();

// Generate a captcha image and output the image to user-agent
header('Content-Type: image/png');
echo $captcha->getCaptcha();

// To verify user input at a later time
if ($captcha->isValid($_POST['captcha'])) {
    // ... captcha is valid
}

/*
 * @desc You can also customize look and feel of your image, change font, background or text color and lot more.
 */
$image = $captcha->getCaptcha()
    ->setBackgroundColor('#000')
    ->setForegroundColor('#efefef')
    ->setFont(Ank\CaptchaImage::FONT_ACME)
    ->setSize(256, 96)
    ->setQuality(100);

echo $image;