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_Validate_Digits validates if a given value contains only digits.

Supported options for Zend_Validate_Digits

There are no additional options for Zend_Validate_Digits:

Validating digits

To validate if a given value contains only digits and no other characters, simply call the validator like shown in this example:

= new Zend_Validate_Digits();

$validator->isValid("1234567890"); // returns true
$validator->isValid(1234);         // returns true
$validator->isValid('1a234');      // returns false

Validating numbers

When you want to validate numbers or numeric values, be aware that this validator only validates digits. This means that any other sign like a thousand separator or a comma will not pass this validator. In this case you should use Zend_Validate_Int or Zend_Validate_Float.

Zend Framework