Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
オブジェクトで三項演算子を利用したいと思います。
if($msg == 'hello'){ $o->setHello('hello'); else $o->setHello('bye');
どうすればそれができますか?
ありがとう
$o->setHello($msg == 'hello' ? 'hello' : 'bye');
どうですか?
これを試して:
($msg == 'hello') ? $o->setHello('hello') : $o->setHello('bye');