Sunday, July 30, 2006

PHP - Numeric validation from forms

In the case where $quantity is a string like "aaa"
settype( $quantity, "integer" )

returns TRUE and $quantity becomes zero.

It is better to use is_numeric( $quantity )
This returns FALSE if $quantity is a string or blank.

No comments: