mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-12-15 10:57:11 +01:00
72 lines
1.3 KiB
Plaintext
72 lines
1.3 KiB
Plaintext
|
Ternary operator
|
||
|
-----
|
||
|
<?php
|
||
|
|
||
|
// ternary
|
||
|
$a ? $b : $c;
|
||
|
$a ?: $c;
|
||
|
|
||
|
// precedence
|
||
|
$a ? $b : $c ? $d : $e;
|
||
|
$a ? $b : ($c ? $d : $e);
|
||
|
-----
|
||
|
array(
|
||
|
0: Expr_Ternary(
|
||
|
cond: Expr_Variable(
|
||
|
name: a
|
||
|
)
|
||
|
if: Expr_Variable(
|
||
|
name: b
|
||
|
)
|
||
|
else: Expr_Variable(
|
||
|
name: c
|
||
|
)
|
||
|
)
|
||
|
1: Expr_Ternary(
|
||
|
cond: Expr_Variable(
|
||
|
name: a
|
||
|
)
|
||
|
if: null
|
||
|
else: Expr_Variable(
|
||
|
name: c
|
||
|
)
|
||
|
)
|
||
|
2: Expr_Ternary(
|
||
|
cond: Expr_Ternary(
|
||
|
cond: Expr_Variable(
|
||
|
name: a
|
||
|
)
|
||
|
if: Expr_Variable(
|
||
|
name: b
|
||
|
)
|
||
|
else: Expr_Variable(
|
||
|
name: c
|
||
|
)
|
||
|
)
|
||
|
if: Expr_Variable(
|
||
|
name: d
|
||
|
)
|
||
|
else: Expr_Variable(
|
||
|
name: e
|
||
|
)
|
||
|
)
|
||
|
3: Expr_Ternary(
|
||
|
cond: Expr_Variable(
|
||
|
name: a
|
||
|
)
|
||
|
if: Expr_Variable(
|
||
|
name: b
|
||
|
)
|
||
|
else: Expr_Ternary(
|
||
|
cond: Expr_Variable(
|
||
|
name: c
|
||
|
)
|
||
|
if: Expr_Variable(
|
||
|
name: d
|
||
|
)
|
||
|
else: Expr_Variable(
|
||
|
name: e
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
)
|