Captcha class

The following sections explain each method of the class.

create_better_captcha (from v2.1.0)

public static array create_better_captcha ( string $savePath, int $imageWidth = 200, int $imageHeight = 50, string $allowedLettersType = 'alpha', string $imageType = 'png', array $backgroundColor = array('r' => 255, 'g' => 255, 'b' => 255), int $linesInCaptcha = 3, array $linesInCaptchaColor = array('r' => 64, 'g' => 64, 'b' => 64), int $pointsInCaptcha = 1000, array $pointsInCaptchaColor= array('r' => 0, 'g' => 0, 'b' => 255))

Creates an improved captcha that uses less server resources as the method create_captcha . It can be almost all setting. The size of the captcha to the background color and depth of field.

Parameter list

The absolute path to the location of the newly created captchas.


The captcha width. From the spacing of the characters in the captcha will be charged.


The captcha height.


Here you can set which characters the captcha should be collected. Following terms are allowed:

  • alnum -0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
  • numeric-0123456789
  • nozero -123456789
  • alpha-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz


Specifies which type of image should be the captcha image. The following types are allowed:

  • png
  • jpg
  • gif


Is an array that specifies the background color in RGB (red, green, blue).


The captcha is more difficult to identify, you can insert so-called dividing lines. These are randomly going through the image and make it more difficult so that recognize the characters. Set to 3 by default.


Is an array that specifies the divisions in RGB (red, green, blue) color.


A certain structure in the captcha to get and thus tell the character to make it difficult, you can insert so-called points in the captcha. The more it is so heavy to recognize the signs. 1000 put on by default.


Is an array that specifies the points in RGB (red, green, blue) color.

create_captcha (deprecated as of v2.1.0, away from v2.3.0)

public static array create_captcha ( String $img_path = '', String $img_url = '', String $font_path = '', Integer $fontSize = 5, Float $imgWidth = 150, Float $imgHeight = 30)

Using the create_captcha method, you can easily a little captcha image create that directory is placed in the cache. As a result, returns an associative array, it includes the path to the captcha and the characters that represented your users must type.

Parameter list

The absolute path to the location of the newly created captchas.


The HTTP path to the new captcha location.


The path to the font of the characters on the screen. Empty by default.


This function has no function and will be expanded in future versions.


The width of the captcha image


The height of the captcha image.