Câu hỏi phỏng vấn PHP
Câu hỏi

What is the differences between $a != $b and $a !== $b ?

Câu trả lời

The differences between $a != $b and $a !== $b in PHP are:

  1. Loose vs Strict Comparison:

    • $a != $b performs a loose comparison, which means it checks if the values of $a and $b are equal, but it may perform type juggling (automatic conversion of operands to a common type) if the operands are of different types.
    • $a !== $b performs a strict comparison, which means it checks if the values of $a and $b are equal and if they are of the same type.
  2. Type Juggling:

    • With $a != $b, if the operands are of different types, PHP may perform type juggling to convert them to a common type before comparing their values.
    • For example, "5" != 5 will return false because the string "5" is converted to the integer 5 before the comparison.
    • However, "5" !== 5 will return true because the string "5" and the integer 5 are not of the same...
junior

junior

Gợi ý câu hỏi phỏng vấn

junior

What is stdClass in PHP?

junior

Explain usage of enumerations in PHP

senior

What is the best method to merge two PHP objects?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào