1.2.1067. Sequences In For

For() instructions allow several instructions in each of its parameters. Then, the instruction separator is comma ‘,’, not semi-colon, which is used for separating the 3 arguments.

This loop will simultaneously increment $a and $b. It will stop only when the last of the central sequence reach a value of false : here, when $b reach 20 and $a will be 6.

This structure is rarely used, and makes the for() instruction quite difficult to read. It is also easy to oversee the multiples instructions, and omit one of them.

It is recommended not to use it.

<?php
   for ($a = 0, $b = 0; $a < 10, $b < 20; $a++, $b += 3) {
    // For loop
   }
?>

1.2.1067.1. Specs

Short name

Structures/SequenceInFor

Rulesets

All, Surprising

Exakat since

0.8.4

PHP Version

All

Severity

Time To Fix

Precision

Very high

Features

for

Available in

Entreprise Edition, Exakat Cloud