Let's say I have a variable that will always be a string.
Now take the code below:
if($myVar === "teststring")
Note: $myVar
will always be a string, so my questions is
Which is quicker/best, using ===
(indentity) or the ==
(equality)?
Testing for identity is always faster, because PHP does not have to Type Juggle to evaluate the comparison. However, I'd say the speed difference is in the realms of nanoseconds and totally neglectable.
Related reading:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With