[drupal-devel] PHP 101: isset() does not check for zero
sdondley at gmail.com
Fri Oct 14 12:33:36 UTC 2005
I was thinking, this problem also stems from the fact that sometimes
fields have a NULL value in the database and sometimes are stored as
empty strings. We will probably want to settle on a way of storing
string in the database, too.
On 10/13/05, Nedjo Rogers <nedjo at gworks.ca> wrote:
> Awhile back I posted a similar question, see below. We have a need for some
> standard guidelines on when to use which test for empty, null, or set
> variables, arrays, and object properties.
> I find I'm sometimes not sure which types of test I should apply to test if
> a variable (or array key) is null or empty.
> Looking at the code, I see various usages:
> if (is_null($variable))
> if (empty($variable))
> if ($variable == NULL)
> if ($variable === NULL)
> if ($objectname->propertyname)
> if (array_key_exists($key, $arrayname))
> if ($arrayname['key'])
> Can anyone point to or suggest a limited set of tests that we should use,
> and guidelines for when each should be applied? This would be a useful
> addition to the coding standards, http://drupal.org/node/318. Thanks!
Communicate or Die: American Labor Unions and the Internet
More information about the drupal-devel