1.2.84. Blind Variable Used Beyond Loop¶
Foreach() loops defines variables, which are traditionally used only inside the loop block. Using them beyond that limit often leads to surprises.
<?php
foreach($a as $b => $c) {
echo "$b : $c\n";
}
// $b is set inside the loop, but used beyond
$max = $b;
?>
1.2.84.1. Specs¶
Short name |
Structures/BlindVariableUsedBeyondLoop |
Rulesets |
|
Exakat since |
2.5.3 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Medium |
Available in |