Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store


Zend_Captcha_Word is an abstract adapter that serves as the base class for most other CAPTCHA adapters. It provides mutators for specifying word length, session TTL, the session namespace object to use, and the session namespace class to use for persistence if you do not wish to use Zend_Session_Namespace. Zend_Captcha_Word encapsulates validation logic.

By default, the word length is 8 characters, the session timeout is 5 minutes, and Zend_Session_Namespace is used for persistence (using the namespace "Zend_Form_Captcha_<captcha ID>").

In addition to the methods required by the Zend_Captcha_Adapter interface, Zend_Captcha_Word exposes the following methods:

  • setWordLen($length) and getWordLen() allow you to specify the length of the generated "word" in characters, and to retrieve the current value.

  • setTimeout($ttl) and getTimeout() allow you to specify the time-to-live of the session token, and to retrieve the current value. $ttl should be specified in seconds.

  • setUseNumbers($numbers) and getUseNumbers() allow you to specify if numbers will be considered as possible characters for the random work or only letters would be used.

  • setSessionClass($class) and getSessionClass() allow you to specify an alternate Zend_Session_Namespace implementation to use to persist the CAPTCHA token and to retrieve the current value.

  • getId() allows you to retrieve the current token identifier.

  • getWord() allows you to retrieve the generated word to use with the CAPTCHA. It will generate the word for you if none has been generated yet.

  • setSession(Zend_Session_Namespace $session) allows you to specify a session object to use for persisting the CAPTCHA token. getSession() allows you to retrieve the current session object.

All word CAPTCHAs allow you to pass an array of options to the constructor, or, alternately, pass them to setOptions(). You can also pass a Zend_Config object to setConfig(). By default, the wordLen, timeout, and sessionClass keys may all be used. Each concrete implementation may define additional keys or utilize the options in other ways.


Zend_Captcha_Word is an abstract class and may not be instantiated directly.

Zend Framework