goto
is an unstructured control flow statement. It makes code less readable and maintainable. Structured control flow statements such
as if
, for
, while
, continue
or break
should be used instead.
Noncompliant code example
$i = 0;
loop:
echo("i = $i");
$i++;
if ($i < 10){
goto loop;
}
Compliant solution
for ($i = 0; $i < 10; $i++){
echo("i = $i");
}