In PHP, how does == differ from ===?
- A.
==only works for numbers while===works for every type - B.
==compares values while===compares the variables' memory addresses - C.
===compares both type and value with no coercion - D.
===is slower than==because it also compares the type
Answer: C
== type-juggles both sides to the same type before comparing, so '1' == '01' is true. === requires the same type and the same value, with no juggling — '1' === '01' is false. Default to === to avoid surprises.
References