1. Go to this page and download the library: Download s1syphos/php-simple-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/ */
s1syphos / php-simple-captcha example snippets
impleCaptcha\Builder;
# First, you have to instantiate it ..
# (1) .. either this way ..
$builder = new Builder;
# (2) .. or this way
$builder = Builder::create();
# Now, building a captcha is easy
$builder->build();
# Create random phrase ..
# (1) .. consisting of 32 characters
# (2) .. being randomly chosen from 'abc@123'
$phrase = Builder::buildPhrase(32, 'abc@123');
# Now proceed like above ..
# (1) .. either this way ..
$builder = new Builder($phrase);
# (2) .. or this way
$builder = Builder::create($phrase);
$builder->save('out.jpg');
# GIF & PNG are also supported, so this works too:
$builder->save('out.png');
$builder->save('out.gif');
# Optionally, quality may be specified:
# - JPG: 0-100
# - PNG: 0-9
$builder->save('low-quality.jpg', 40);
# Default: JPG & 90
$builder->output();
# .. but how about ..
$builder->output(6, 'png');
<img src="<?= $builder->inline()
# Example: storing the phrase in the session to test for the user input later
$_SESSION['phrase'] = $builder->phrase;