What is the difference between null and empty?

前端 未结 9 1490
一向
一向 2020-12-02 16:32

I am new to the concept of empty and null. Whilst I have endeavoured to understand the difference between them, I am more confused. I came across an article at http://www.tu

9条回答
  •  天涯浪人
    2020-12-02 16:43

    NULL is a special value which explicitly states that the variable has not been set to any value yet. Be careful with using the empty() function as you can't just determine that a variable is exactly NULL using it. For example the empty() function will return true if an int is set to 0. If you need to make sure a variable is exactly NULL use if($variable == NULL).

    For more info on empty() see http://php.net/manual/en/function.empty.php

提交回复
热议问题