Possible Duplicate:
How can I understand nested ?: operators in PHP?
Why does this:
$object->customer->phone =
! empty( $object->customer->address->phone_fixed ) ?
$object->customer->address->phone_fixed :
! empty( $object->customer->address->phone_mobile ) ?
$object->customer->address->phone_mobile :
! empty( $object->customer->address->phone_business ) ?
$object->customer->address->phone_business : '';
returns $object->customer->address->phone_business, even if $object->customer->address->phone_fixed is set and not empty?
Thank you.
It has to do with the associativity of the ternary operator. I would at a minimum add parens to your code; but honestly… more than one ternary in a single statement is a modern faux-pas . Interesting link