I need PHP code that would check a variable and see whether or not it's blank. I'm using Drupal and CCK and I want the code to check and see if there is a value set for that field.
You can use isset or check to see if its value is null or "". Check out php.net for usage. Also, while testing, you can have it print to html (echo) to manually check if everything is working.
Yeah I've already checked out isset but it's not able to tell whether or not a value has been entered for the variable. It can only tell if the variable exists.
I would say try empty() but I don't know if that's the result you're looking for. http://us2.php.net/manual/en/function.empty.php
The problem with functions like empty() and isset() is that they make assumptions (sometimes terrible ones) about the data value. empty(), for example, returns TRUE for integers with value '0', even though '0' is, technically, a "value". And isset() returns FALSE for null, whereas null might also sometimes be considered a valid value. The bottom line is that it really depends on context. For every variable you need validate, be it string or integer or float or array or whatever, you might need to do several different kinds of checks and tests, all based on context. Such are the vagaries of a loosely-typed language.