1<documentation title="For Loops With Function Calls in the Test"> 2 <standard> 3 <![CDATA[ 4 For loops should not call functions inside the test for the loop when they can be computed beforehand. 5 ]]> 6 </standard> 7 <code_comparison> 8 <code title="Valid: A for loop that determines its end condition before the loop starts."> 9 <![CDATA[ 10<em>$end = count($foo);</em> 11for ($i = 0; $i < $end; $i++) { 12 echo $foo[$i]."\n"; 13} 14 ]]> 15 </code> 16 <code title="Invalid: A for loop that unnecessarily computes the same value on every iteration."> 17 <![CDATA[ 18for ($i = 0; $i < <em>count($foo)</em>; $i++) { 19 echo $foo[$i]."\n"; 20} 21 ]]> 22 </code> 23 </code_comparison> 24</documentation> 25