2011-11-27 11:20:35 +01:00
|
|
|
Switch
|
|
|
|
-----
|
|
|
|
<?php
|
|
|
|
|
|
|
|
switch ($a) {
|
|
|
|
case 0:
|
2018-01-30 23:06:20 +01:00
|
|
|
break;
|
|
|
|
// Comment
|
2011-11-27 11:20:35 +01:00
|
|
|
case 1;
|
|
|
|
default:
|
|
|
|
}
|
2011-12-04 16:52:43 +01:00
|
|
|
|
|
|
|
// alternative syntax
|
|
|
|
switch ($a):
|
|
|
|
endswitch;
|
|
|
|
|
|
|
|
// leading semicolon
|
|
|
|
switch ($a) { ; }
|
|
|
|
switch ($a): ; endswitch;
|
2011-11-27 11:20:35 +01:00
|
|
|
-----
|
|
|
|
array(
|
|
|
|
0: Stmt_Switch(
|
|
|
|
cond: Expr_Variable(
|
|
|
|
name: a
|
|
|
|
)
|
|
|
|
cases: array(
|
|
|
|
0: Stmt_Case(
|
|
|
|
cond: Scalar_LNumber(
|
|
|
|
value: 0
|
|
|
|
)
|
|
|
|
stmts: array(
|
2018-01-30 23:06:20 +01:00
|
|
|
0: Stmt_Break(
|
|
|
|
num: null
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
2012-10-19 14:54:56 +02:00
|
|
|
)
|
|
|
|
1: Stmt_Case(
|
2011-11-27 11:20:35 +01:00
|
|
|
cond: Scalar_LNumber(
|
|
|
|
value: 1
|
|
|
|
)
|
2012-10-19 14:54:56 +02:00
|
|
|
stmts: array(
|
|
|
|
)
|
2018-01-30 23:06:20 +01:00
|
|
|
comments: array(
|
|
|
|
0: // Comment
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
2: Stmt_Case(
|
2012-10-19 14:54:56 +02:00
|
|
|
cond: null
|
2011-11-27 11:20:35 +01:00
|
|
|
stmts: array(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2011-12-04 16:52:43 +01:00
|
|
|
1: Stmt_Switch(
|
|
|
|
cond: Expr_Variable(
|
|
|
|
name: a
|
|
|
|
)
|
|
|
|
cases: array(
|
|
|
|
)
|
2016-03-09 18:57:16 +01:00
|
|
|
comments: array(
|
|
|
|
0: // alternative syntax
|
|
|
|
)
|
2011-12-04 16:52:43 +01:00
|
|
|
)
|
|
|
|
2: Stmt_Switch(
|
|
|
|
cond: Expr_Variable(
|
|
|
|
name: a
|
|
|
|
)
|
|
|
|
cases: array(
|
|
|
|
)
|
2016-03-09 18:57:16 +01:00
|
|
|
comments: array(
|
|
|
|
0: // leading semicolon
|
|
|
|
)
|
2011-12-04 16:52:43 +01:00
|
|
|
)
|
|
|
|
3: Stmt_Switch(
|
|
|
|
cond: Expr_Variable(
|
|
|
|
name: a
|
|
|
|
)
|
|
|
|
cases: array(
|
|
|
|
)
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|