Reputation:
I wanna make use of the Ternary Operator with an object.
if($msg == 'hello'){
$o->setHello('hello');
else
$o->setHello('bye');
How could I do that?
Thanks
Upvotes: 3
Views: 806
Reputation: 25263
Try this:
($msg == 'hello') ? $o->setHello('hello') : $o->setHello('bye');
Upvotes: 2