NULL vs Empty when dealing with user input

前端 未结 8 2020
一整个雨季
一整个雨季 2021-02-06 11:57

Yes, another NULL vs empty string question.

I agree with the idea that NULL means not set, while empty string means \"a value that is empty\". Here\'s my problem: If the

8条回答
  •  醉酒成梦
    2021-02-06 12:23

    I have always used NULL for uninitialized values, empty for purposely empty values and 0 for off indicators.

    By doing this all the time, it is there even if I am not using it, but I don't have to do anything different if I need that distinction.

    I am usually testing for empty(), but sometimes I check for isset() which evaluates false on NULL. This is useful for reminders to answer certain questions. If it is empty, false or 0 then the question is answered.

提交回复
热议问题