Isset Vs If Exists , Decoding PHP’s Empty Value Functions: When to Use Which
Di: Samuel
Using unset on an undefined variable will not cause any errors (unless the variable is the index of an array (or object) that doesn’t exist). It takes the performance advantage of isset() while maintaining the correct checking result (i. Being more explicit in these cases will help readers of your code. I had bad experience. This tip was reposted from my blog, jontai. You are correct in using not on this, as you want it to tell you if the cookie doesn’t exist (opposite). Thanks – ptvty.Of course, it’s usually just easier to use the built-in empty() function.On the other hand, isset() will return true as long as a variable is defined and its value is not NULL. Try to add a name to text input to access its value: