How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?

前端 未结 11 2126
故里飘歌
故里飘歌 2020-11-22 16:52

What is the difference between == and === in PHP?

What would be some useful examples?


Additionally, how are these operators us

11条回答
  •  爱一瞬间的悲伤
    2020-11-22 17:08

    In regards to JavaScript:

    The === operator works the same as the == operator, but it requires that its operands have not only the same value, but also the same data type.

    For example, the sample below will display 'x and y are equal', but not 'x and y are identical'.

    var x = 4;
    var y = '4';
    if (x == y) {
        alert('x and y are equal');
    }
    if (x === y) {
        alert('x and y are identical');
    }
    

提交回复
热议问题