Common mistakes using a few PHP functions

Common mistakes using a few PHP functions:

  • empty() – commonly mistaken due to different results with different content. Most of the time it will not be necessary to use this function. The usage of this function is discouraged.
  • isset() – commonly misused to verify if the variable has a value. In case of standard variables check against a NULL should be performed. In the case of array values, the array_key_exists check should be performed. Do not use this function.
  • unset() – commonly misused to reset a variable. In case of standard variables assign a NULL value rather than unset it. Only use this function to remove an array value.