Responsive Captcha: A small PHP library for preventing spam

If you’re reading this, you probably already know what a CAPTCHA is. The most common form consists of an image with warped or obscured characters which must be entered into a text field. While these image-based CAPTCHAs tend to be effective at stopping spam, they are also poorly accessible, often slow, and require a third-party service or large font files. Surely there must be a better way.

There is. Text-based CAPTCHAs use simple logic questions to weed out bots while remaining accessible to users with disabilities. I found numerous text CAPTCHA implementations floating around the Web, but I was disappointed that they all either relied on a third-party service or required setting up a database. So I decided to make my own.

The result is Responsive Captcha, a PHP library which generates simple, random arithmetic and logic questions, and can be easily integrated into an existing form.

Some example questions generated by Responsive Captcha include:

  • Which is smallest: eight, sixty-nine, or seven?
  • What is nine minus five?
  • What is the third letter in rainbow?
  • What is eight multiplied by one?

For more examples and instructions for use, check out the project on GitHub:

By Theodore Brown

PHP internals contributor and full-stack developer from Minnesota. Interested in education, astronomy, and the future of programming.