三項演算子を使用してコードを短縮しようとしています。
これは私の元のコードです:
if ($type = "recent") {
$OrderType = "sid DESC";
} elseif ($type = "pop") {
$OrderType = "counter DESC";
} else {
$OrderType = "RAND()";
}
if
コードでs/ sの代わりに三項演算子を使用するにはどうすればよいelse
ですか?
$OrderType = ($type = "recent") ? "sid DESC" : "counter DESC" ;
これは私が試したコードですが、「<code>elseifpart」を追加する方法がわかりません。