What's the difference of the two codes?


I’m wondering on this what’s the difference on this? I know it produces the same result.
In WordPress twentyseventeen theme I see this code

if ( 'one-column' === $page_layout ) {

it’s the same of

if ( $page_layout == 'one-column' ) {

not really sure what’s the difference and what’s best to use. Any thoughts?

Thank you!


Strict equality (===) means values which we are comparing must have the same type.

This means “2” will not be equal to 2 (“2”===2 it will return false)

Type converting equality (==) means automatically it will covert the variable to value irrespective of data type; either it is a string or a number.

This means “2” will be equal to 2 (“2” == 2 it will return true).


Thanks man.

1 Like