Example
Once loaded you can generate a captcha like this:
$vals = array(
'word' => 'Random word',
'img_path' => './captcha/',
'img_url' => 'http://example.com/captcha/',
'font_path' => './path/to/fonts/texb.ttf',
'img_width' => '150',
'img_height' => 30,
'expiration' => 7200
);
$cap = create_captcha($vals);
echo $cap['image'];
- The captcha function requires the GD image library.
- Only the
img_path
and img_url
are required.
- If a "word" is not supplied, the function will generate a random ASCII string. You might put together your own word library that you can draw randomly from.
- If you do not specify a path to a TRUE TYPE font, the native ugly GD font will be used. The "captcha" folder must be writable (666, or 777)
- The "expiration" (in seconds) signifies how long an image will remain in the captcha folder before it will be deleted. The default is two hours.