I want to use the ternary operator with an object.
if($msg == 'hello'){ $o->setHello('hello'); else $o->setHello('bye');
How can i do this?
thanks
Try the following:
($msg == 'hello') ? $o->setHello('hello') : $o->setHello('bye');
$o->setHello($msg == 'hello' ? 'hello' : 'bye');
What about?