Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How did you learn PHP? Reply To: How did you learn PHP?

#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.