1.2.1159. Strict Or Relaxed Comparison

PHP has two comparison styles : strict and relaxed.

The analyzed code has less than 10% of one of them : for consistency reasons, it is recommended to make them all the same.

It is recommended to always use the strict comparison by default, and use the relaxed in case of specific situations.

<?php

// This compares $strict both in terms of value and type
if ($strict === 3) {

} elseif ($strict == 3) {
    // This compares $strict after an possible type casting.
    // '3', 3.0 or 3 would all be possible solutions.
}

?>

See also Comparison Operators.

1.2.1159.1. Specs

Short name

Structures/ComparisonFavorite

Rulesets

All, Preferences

Exakat since

1.3.2

PHP Version

All

Severity

Time To Fix

Precision

High

Features

comparison

Available in

Entreprise Edition, Exakat Cloud