Hello,
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
Hello,
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
Try this:
($msg == 'hello') ? $o->setHello('hello') : $o->setHello('bye');