PHP Simplify a ternary operation
Posted
by Obay
on Stack Overflow
See other posts from Stack Overflow
or by Obay
Published on 2010-06-13T23:43:19Z
Indexed on
2010/06/13
23:52 UTC
Read the original article
Hit count: 148
php
|ternary-operator
In PHP, is there a way to simplify this even more, without using an if()
?
$foo = $bar!==0 ? $foo : '';
I was wondering if there was a way to not reassign $foo
to itself if the condition is satisfied. I understand there is a way to do this in Javascript (using &&, right?), but was wondering if there was a way to do this in PHP.
© Stack Overflow or respective owner