コード
<?php
$test = 1;
echo ($test === 2 ? '○' : ($test === 1 ? '◎' : '×') );
echo ($test === 2 ? '○'
: ($test === 1 ? '◎'
: '×'
));
<?php
$test = 3;
echo ($test === 2 ? '○'
: ($test === 1 ? '◎'
: ($test === 3 ? 'a'
: 'b'
)));
$test = 77;
echo ($test === 2 ? '○'
: ($test === 1 ? '◎'
: ($test === 3 ? 'a'
: ($test === 4 ? 'c'
: 'b'
))));
javascript
process.stdin.resume();
process.stdin.setEncoding('utf8');
test = 1;
console.log(test === 2 ? '○' : (test === 1 ? '◎' : '×') );
結果
◎
javascript 入れ子
process.stdin.resume();
process.stdin.setEncoding('utf8');
let x = 5;
let a = x < 10 ? 1
: x < 20 ? 2
: x < 30 ? 3
: 4;
console.log(a);
結果
1