PHP Classes

File: test/php/test.php

Recommend this page to a friend!
  Classes of Nikos M.  >  Simple PHP Captcha Library  >  test/php/test.php  >  Download  
File: test/php/test.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple PHP Captcha Library
Show images to verify humans with math expressions
Author: By
Last change: v.2.2.0

* support scale distortion vs position distortion
* add option(distortion_type)
* update tests
Date: 1 month ago
Size: 1,166 bytes
 

Contents

Class file image Download
<?php

include(dirname(__FILE__).'/../../src/php/SimpleCaptcha.php');

function
test()
{
   
$captcha = (new SimpleCaptcha())
            ->
option('secret_key', 'SECRET_KEY')
            ->
option('secret_salt', 'SECRET_SALT_')
            ->
option('num_terms', 2)
            ->
option('max_num_terms', 3) // -1 means constant num_terms
           
->option('min_term', 1)
            ->
option('max_term', 21)
            ->
option('color', 0x121212) // text color
           
->option('background', 0xffffff) // background color
   
;

   
$captcha->reset();
   
$captcha->option('difficulty', 2); // 0 (easy) to 3 (difficult)
   
$captcha->option('distortion_type', 1); // 1: position distortion

   
echo $captcha->getCaptcha() . PHP_EOL;
    echo
PHP_EOL;
    echo
$captcha->getHash() . PHP_EOL;

    echo
PHP_EOL . PHP_EOL;

   
$captcha->reset();
   
$captcha->option('difficulty', 2); // 0 (easy) to 3 (difficult)
   
$captcha->option('distortion_type', 2); // 2: scale distortion

   
echo $captcha->getCaptcha() . PHP_EOL;
    echo
PHP_EOL;
    echo
$captcha->getHash() . PHP_EOL;
}

echo
'SimpleCaptcha::VERSION ' . SimpleCaptcha::VERSION . PHP_EOL;

test();

For more information send a message to info at phpclasses dot org.