What makes a difference between if(!empty($example)) and if($example)?
I don't find any example when this would print a different result.
Difference between if($example), if(!empty($example))?
Moderator: General Moderators
Re: Difference between if($example), if(!empty($example))?
They won't print different result, but the first one is more readable, especially if you are dealing with array. If the variable is not an array, there is no difference (and again, the difference would be just in the readability).
Other than that, the only difference is that empty() won't triger notice if the variable is not defined.
Other than that, the only difference is that empty() won't triger notice if the variable is not defined.
Re: Difference between if($example), if(!empty($example))?
Now I see about the trigger notice. So I assume that recommended use is isset, right?