PHP considers null is equal to zero

前端 未结 11 2043
眼角桃花
眼角桃花 2020-12-05 12:50

In php, ($myvariable==0) When $myvariable is zero, the value of the expression is true; when $myvariable is null, the value of this expression is also true. How

11条回答
  •  鱼传尺愫
    2020-12-05 13:08

    If your zero could be a string, you should also considere checking the "zero string"

    ($myvariable === 0 || $myvariable === '0')
    

提交回复
热议问题