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 are PSRs? Choose 1 and briefly describe it

senior

What does a $$$ mean in PHP?

senior

What are the disadvantages of using persistent connection in PDO?

Bình luận

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

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