Tuesday, February 26, 2008

PHP and NULL comparisons

Just a little gotcha in PHP and ms sql access:

If you fetch a row from my sql, and are trying to compare a field value to see if it is NULL, use the === operator. The == operator will trigger a type conversion inside PHP and make null == 0 returns true.

Reference: http://ca.php.net/manual/en/types.comparisons.php

No comments: