Posted by Azeus on 08/22/05 15:26
Sonic wrote:
> <?php
>
> function foo($bar)
> {
> return print($bar);
> }
>
> if ( print("a") | print("b") );
> echo "<br>";
> if ( print("a") || print("b") );
> echo "<br>";
> if ( print("a") or print("b") );
> echo "<br>";
>
> echo "<br>";
> if ( foo("a") | foo("b") );
> echo "<br>";
> if ( foo("a") || foo("b") );
> echo "<br>";
> if ( foo("a") or foo("b") );
>
> ?>
>
> What is the difference?
>
>
Difference is Logical or bitwise operators.
"or" and "||" are logical operators. "|" is a bitwise operator.
> if ( print("a") || print("b") )
logical operator
check either expression is true.
> if ( print("a") | print("b") );
ahem ^^ .... now if you want to use bitwise operators do something
like this:
if( $val & 1 ) {
echo "value is odd" ;
}
http://www.php.net/manual/en/language.operators.php
Navigation:
[Reply to this message]
|