What is the difference between null and empty?

前端 未结 9 1477
一向
一向 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 17:00

    The empty() is a nice fast way to see if the variable holds any useful info... that is for strings empty() returns true for a string of "" as well as a null string.

    So you can write something like this:

    if (! empty($name)) echo $name;
    

    More info see here: PHP: empty()

提交回复
热议问题