You are here: Re: Whats the diffecence between '&' and '&&' operators? « PHP Language « IT news, forums, messages
Re: Whats the diffecence between '&' and '&&' operators?

Posted by Jam Pa on 05/25/05 18:54

Jam Pa <anonanon@non-anon.org> wrote in
news:Xns9661B5FF25BABanonanonnonanonorgjp@213.243.153.2:

> Both '&' and '&&' are 'AND' right? Or what about 'ORs' '|' and '||'?
> Whats the difference? I not grok....

Here is an example test for those interested.

<?php
$a = "nil"; $b = "nil";
if (($a=true) | ($b=false)) { echo " * 1: true, a: $a , b: $b <br>"; }
$a = "nil"; $b = "nil";
if (($a=false) | ($b=true)) { echo " * 2: true, a: $a , b: $b <br>"; }
$a = "nil"; $b = "nil";
if (($a=true) || ($b=false)) { echo " * 3: true, a: $a , b: $b <br>"; }
$a = "nil"; $b = "nil";
if (($a=false) || ($b=true)) { echo " * 4: true, a: $a , b: $b <br>"; }
$a = "nil"; $b = "nil";
?>

output with comments
* 1: true, a: 1 , b:

* 2: true, a: , b: 1
- both evaluated above

* 3: true, a: 1 , b: nil
- only first one evaluated (it was true)
)
* 4: true, a: , b: 1
- both

Hmm, not sure if I'm really any wiser...

 

Navigation:

[Reply to this 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

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