I am wondering if you use unset variables, empty strings (or 0's), or "None" to determine if a variable is "None"?
The case I'm thinking of is, I'm retrieving something from the database, but find that the value is not set for the record, usually determined by the fact that there are no records or a null value. This will display to the user as "None" or "Not Set".
So the question is, when passing this value to another part of the script (ie, another function, farter on the script, template, etc), do I:
- not set the variable (and therefore check if it's set in the template)
- set the variable to an empty string or 0 (and check for the empty string in the template)
- set the variable to "None" or "Not Set" and just echo the variable
Is there one that you usually do and why do you do it?
(I'm using PHP, so the type of the variable is somewhat unimportant.)
I'm looking for a general answer; I know that it won't always be true, but a general rule to follow.