PHP has different functions which can be used to test the value of a variable. Three useful functions for this are isset(), empty() and isnull(). All these function return a boolean value. If these functions are not used in correct way they can cause unexpected results. Is there a single function that can be created to tell whether a variable is NULL or undefined in PHP? I will pass the variable to the function (by reference if needed) but I wont know the name of the variable until runtime. isset() and isnull 0) echo at least one variable is not 0 else echo both variables 0 for more information.
Setting a variable to null is only useful for cases as with the one you circle around everzet - having it as a functions default variable.agaezcode commented Mar 6, 2015. php Echo number if the number is not zero. echo Variable is not NULLVariable is not NULL. View the example in the browser. Practice here online: See also. PHP Function Reference. I would like to know if we have a similar statement in PHP, not being isset() but literally checking for an undefined value, something likeIt will store true if variable is defined else false. If need the invers the simply remove the !. Note : Returns TRUE if var exists and has value other than NULL, FALSE There is a difference between an unset variable and null: a variable that has a null value is an entry in PHPs list of extant variables.Null checks if variable equals to zero-byte (0). Depends what fits your needs.