What does “===” mean?

前端 未结 10 1451
一生所求
一生所求 2020-11-27 06:01

I\'ve noticed someone using the PHP operator === which I can\'t make sense out of. I\'ve tried it with a function, and it corresponds in crazy ways.

Wha

10条回答
  •  执笔经年
    2020-11-27 06:36

    $x == $y is TRUE if the value of the $x and $y are same:

    $x = 1; //int type
    $y = "1"; //string type
    if ($x == $y) {
        // This will execute
    }
    

    $x === $y TRUE if the value of the $x and $y are same and type of $x and $y are same:

    $x = 1; //int type
    $y = "1"; //string type
    if ($x === $y) {
        // This will not execute
    }
    

提交回复
热议问题