Here is the quick article which shows the difference between two PHP functions which are isset() and array_key_exists().
One basic difference is that isset() can be used with array and variables both while array_key_exists() can be used with the arrays only.
But the major difference lies in the values they return on certain condition. Main difference comes into picture while you are dealing with the NULL values.
So now lets check the major difference now.
Both this function return TRUE on success and FALSE on error. Here success means variable is available and error means variable is not available.
array_key_exists() will check for the existence of the key only. This function will return true even if that array element contain the NULL. Have a look at below code block for the same.
Unlike array_key_exists(), isset() will check the existence plus the value of the varible. This function will return true only if variable is exists and contain non null value. So this function will return false even if variable is exists but contain the NULL value.
Have a look at below code block for the same:
Here is the difference between these two functions, now be careful while using any of the function mentioned above.
Subscribe to our RSS feed for more PHP tips.
Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.
View all posts by: Avinash