1Ternary operator 2----- 3<?php 4 5// ternary 6$a ? $b : $c; 7$a ?: $c; 8 9// precedence 10$a ? $b : $c ? $d : $e; 11$a ? $b : ($c ? $d : $e); 12 13// null coalesce 14$a ?? $b; 15$a ?? $b ?? $c; 16$a ?? $b ? $c : $d; 17$a && $b ?? $c; 18----- 19array( 20 0: Stmt_Expression( 21 expr: Expr_Ternary( 22 cond: Expr_Variable( 23 name: a 24 ) 25 if: Expr_Variable( 26 name: b 27 ) 28 else: Expr_Variable( 29 name: c 30 ) 31 ) 32 comments: array( 33 0: // ternary 34 ) 35 ) 36 1: Stmt_Expression( 37 expr: Expr_Ternary( 38 cond: Expr_Variable( 39 name: a 40 ) 41 if: null 42 else: Expr_Variable( 43 name: c 44 ) 45 ) 46 ) 47 2: Stmt_Expression( 48 expr: Expr_Ternary( 49 cond: Expr_Ternary( 50 cond: Expr_Variable( 51 name: a 52 ) 53 if: Expr_Variable( 54 name: b 55 ) 56 else: Expr_Variable( 57 name: c 58 ) 59 ) 60 if: Expr_Variable( 61 name: d 62 ) 63 else: Expr_Variable( 64 name: e 65 ) 66 ) 67 comments: array( 68 0: // precedence 69 ) 70 ) 71 3: Stmt_Expression( 72 expr: Expr_Ternary( 73 cond: Expr_Variable( 74 name: a 75 ) 76 if: Expr_Variable( 77 name: b 78 ) 79 else: Expr_Ternary( 80 cond: Expr_Variable( 81 name: c 82 ) 83 if: Expr_Variable( 84 name: d 85 ) 86 else: Expr_Variable( 87 name: e 88 ) 89 ) 90 ) 91 ) 92 4: Stmt_Expression( 93 expr: Expr_BinaryOp_Coalesce( 94 left: Expr_Variable( 95 name: a 96 ) 97 right: Expr_Variable( 98 name: b 99 ) 100 ) 101 comments: array( 102 0: // null coalesce 103 ) 104 ) 105 5: Stmt_Expression( 106 expr: Expr_BinaryOp_Coalesce( 107 left: Expr_Variable( 108 name: a 109 ) 110 right: Expr_BinaryOp_Coalesce( 111 left: Expr_Variable( 112 name: b 113 ) 114 right: Expr_Variable( 115 name: c 116 ) 117 ) 118 ) 119 ) 120 6: Stmt_Expression( 121 expr: Expr_Ternary( 122 cond: Expr_BinaryOp_Coalesce( 123 left: Expr_Variable( 124 name: a 125 ) 126 right: Expr_Variable( 127 name: b 128 ) 129 ) 130 if: Expr_Variable( 131 name: c 132 ) 133 else: Expr_Variable( 134 name: d 135 ) 136 ) 137 ) 138 7: Stmt_Expression( 139 expr: Expr_BinaryOp_Coalesce( 140 left: Expr_BinaryOp_BooleanAnd( 141 left: Expr_Variable( 142 name: a 143 ) 144 right: Expr_Variable( 145 name: b 146 ) 147 ) 148 right: Expr_Variable( 149 name: c 150 ) 151 ) 152 ) 153) 154