2011-11-27 11:20:35 +01:00
|
|
|
For loop
|
|
|
|
-----
|
|
|
|
<?php
|
|
|
|
|
|
|
|
// "classical" loop
|
|
|
|
for ($i = 0; $i < $c; ++$i) {}
|
|
|
|
|
|
|
|
// multiple expressions
|
2015-10-02 11:14:31 +02:00
|
|
|
for ($a, $b; $c, $d; $e, $f) {}
|
2011-11-27 11:20:35 +01:00
|
|
|
|
|
|
|
// infinite loop
|
|
|
|
for (;;) {}
|
|
|
|
|
|
|
|
// alternative syntax
|
|
|
|
for (;;):
|
|
|
|
endfor;
|
|
|
|
-----
|
|
|
|
array(
|
|
|
|
0: Stmt_For(
|
|
|
|
init: array(
|
|
|
|
0: Expr_Assign(
|
|
|
|
var: Expr_Variable(
|
|
|
|
name: i
|
|
|
|
)
|
|
|
|
expr: Scalar_LNumber(
|
|
|
|
value: 0
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
cond: array(
|
2014-02-06 14:44:16 +01:00
|
|
|
0: Expr_BinaryOp_Smaller(
|
2011-11-27 11:20:35 +01:00
|
|
|
left: Expr_Variable(
|
|
|
|
name: i
|
|
|
|
)
|
|
|
|
right: Expr_Variable(
|
|
|
|
name: c
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
loop: array(
|
|
|
|
0: Expr_PreInc(
|
|
|
|
var: Expr_Variable(
|
|
|
|
name: i
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
stmts: array(
|
|
|
|
)
|
2016-03-09 18:57:16 +01:00
|
|
|
comments: array(
|
|
|
|
0: // "classical" loop
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
1: Stmt_For(
|
2015-10-01 17:32:51 +02:00
|
|
|
init: array(
|
2015-10-02 11:14:31 +02:00
|
|
|
0: Expr_Variable(
|
|
|
|
name: a
|
2015-10-01 17:32:51 +02:00
|
|
|
)
|
2015-10-02 11:14:31 +02:00
|
|
|
1: Expr_Variable(
|
|
|
|
name: b
|
2015-10-01 17:32:51 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
cond: array(
|
2015-10-02 11:14:31 +02:00
|
|
|
0: Expr_Variable(
|
|
|
|
name: c
|
2015-10-01 17:32:51 +02:00
|
|
|
)
|
2015-10-02 11:14:31 +02:00
|
|
|
1: Expr_Variable(
|
|
|
|
name: d
|
2015-10-01 17:32:51 +02:00
|
|
|
)
|
|
|
|
)
|
2015-10-02 11:14:31 +02:00
|
|
|
loop: array(
|
2011-11-27 11:20:35 +01:00
|
|
|
0: Expr_Variable(
|
2015-10-02 11:14:31 +02:00
|
|
|
name: e
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
1: Expr_Variable(
|
2015-10-02 11:14:31 +02:00
|
|
|
name: f
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
stmts: array(
|
|
|
|
)
|
2016-03-09 18:57:16 +01:00
|
|
|
comments: array(
|
|
|
|
0: // multiple expressions
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
2015-10-02 11:14:31 +02:00
|
|
|
2: Stmt_For(
|
2011-11-27 11:20:35 +01:00
|
|
|
init: array(
|
|
|
|
)
|
|
|
|
cond: array(
|
|
|
|
)
|
|
|
|
loop: array(
|
|
|
|
)
|
|
|
|
stmts: array(
|
|
|
|
)
|
2016-03-09 18:57:16 +01:00
|
|
|
comments: array(
|
|
|
|
0: // infinite loop
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
2015-10-02 11:14:31 +02:00
|
|
|
3: Stmt_For(
|
2011-11-27 11:20:35 +01:00
|
|
|
init: array(
|
|
|
|
)
|
|
|
|
cond: array(
|
|
|
|
)
|
|
|
|
loop: array(
|
|
|
|
)
|
|
|
|
stmts: array(
|
|
|
|
)
|
2016-03-09 18:57:16 +01:00
|
|
|
comments: array(
|
|
|
|
0: // alternative syntax
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
)
|