6 Sep
2005
6 Sep
'05
6:35 p.m.
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']) etc. 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!