Re: Logical OR in assignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Karns wrote:
I once saw the use of OR (|) in assignment.

$x = $y | $z;

Does this use bitwise OR? I'm trying to see if I could use the above
expression in place of:

$x = is_null($y) ? $z : $y;

yes, '|' is bitwise OR, but that is /not/ a ternary operator.

it's not safe to just replace the ternary operation with the bitwise operation.

for example, if $y=5 and $z=9, then:
$x=$y|$z;             -> $x=13
$x=is_null($y)?$z:$y; -> $x=5

Kae

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux