Friday, October 19, 2012

Triple Equals Sign In Php

Since PHP uses $ to declare variables (and not int, etc), one can run into issues with an if statement being unintentionally true.

For example, 0 == null.

The triple equals sign (===) allows you to prevent these cases by only returning true if the two inputs are not the same type.

So, 0 === null is not true. Also, 0 === "0" is not true either.

No comments:

Post a Comment