PHP considers null is equal to zero

前端 未结 11 2002
眼角桃花
眼角桃花 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:12

    To identify as null or zero by:

    • is_int($var) if a variable is a number or a numeric string. To identify Zero, use is_numeric($var) is also the solution or use $var === 0

    • is_null($var) if a variable is NULL

提交回复
热议问题