Home › Forums › Back End › How did you learn PHP? › Reply To: How did you learn PHP?
July 30, 2014 at 10:50 am
#176958
Participant
Is this the answer?
Yes. (Same holds true for javascript.) There are edge cases where you actually want type coercion, but you usually don’t:
if( strpos( "string","s" ) == false ){
echo "The letter 's' is NOT in the word 'string'";
}
Because s
is at position 0
, and 0 == false
, this will claim that “The letter ‘s’ is NOT in the word ‘string’,” whereas using 0 === false
would give the correct result.
Most coders don’t understand the difference between ==
and ===
, or all of the quirks surrounding them, so it’s best to just stick with ===
by default.