Reply to Re: Bug || !Bug

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация