PHP code example of romeoz / rock-captcha

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

    

romeoz / rock-captcha example snippets


use rock\captcha\KCaptcha;

$captcha = new KCaptcha();

echo '<img src="' . $captcha->getDataUri() . '">';

$captcha->getCode(); // output: <code>

$config = [
    'session' => new \rock\session\Session
];
$captcha = new KCaptcha($config);

echo '<img src="' . $captcha->getDataUri() . '">';

$captcha->getSession(); // output: <code>