user12457660
user12457660

Reputation: 19

Why is this less specific conditional different from an explicit one?

if ($args->theme_location === 'header' || $args->theme_location === 'uia') {

evaluates to: (bool) false (bool) True

if ($args->theme_location === 'header' || 'uia') {

evaluates to: (bool) false (bool) True

Upvotes: 0

Views: 26

Answers (1)

Alex Black
Alex Black

Reputation: 462

This condition will always be true. The reason is the different priorities of the operators. === works first, || works after. Therefore $ args-> theme_location === 'header' || 'uia' is always true This is the same as

($args->theme_location === 'header') || 'uia'

Upvotes: 1

Related Questions