代码之家  ›  专栏  ›  技术社区  ›  xRobot

怎么办!==和==PHP中的平均值?[副本]

  •  5
  • xRobot  · 技术社区  · 14 年前

    可能重复:
    How do the equality (== double equals) and identity (=== triple equals) comparison operators differ?
    Reference - What does this symbol mean in PHP?
    php not equal to != and !==

    什么是 !== === 此代码段中的运算符?

    if ( $a !== null ) // do something
    if ( $b === $a ) // do something
    
    6 回复  |  直到 14 年前
        1
  •  6
  •   Sarfraz    14 年前

    if (4 === 4) // same value and type
    {
      // true
    }
    

    if (4 == "4") // same value and different type but == used
    {
      // true
    }
    

    if (4 === "4") // same value but different type
    {
      // false
    }
    

    == ===

        2
  •  13
  •   Gabi Purcaru BornCoder    14 年前

    1 == 1
    1 == "1"
    1 === 1
    1 !== "1"
    true === true
    true !== "true"
    true == "true"
    

    this link

        3
  •  1
  •   Vincent Savard Midhun    14 年前

    "1" == 1 "1" === 1

    if (strpos('hello', 'hello world!'))
    

    if (strpos('hello', 'hello world!') !== false)
    
        4
  •  0
  •   Martin    14 年前

        5
  •  0
  •   user477582    14 年前

        6
  •  0
  •   Baylor Rae'    14 年前

    ==

    if( '1' == 1 ) { echo 'yes'; }
    

    ===

    if( '1' === 1 ) { /* this will not work */ }
    

    '1' string 1 integer number

    if( (integer) '1' === 1 ) { echo 'this works'; }