the single & is a logical AND so a() NOR b() is evaluatet ! its usually used on binary integer. e.g. 0x0001 & 0x0001 = 0x0001 equlals TRUE while 0x0002 & 0x0001 equals FALSE
so something like $a & $b guides to some very interisting results depending of their values but nothing u expect. while && tells 'evaluate' the expressions on both sites and combine its results in an AND operation. thats why compilers and interpreters do have a definition what value TRUE has. its very likely that TRUE is 1 and false is 0 lets say $a = 1 $b = 1 then $a & $b is 1 or true and it would give the same like $a && $b in that case at that point its also to mention that an empty string in PHP is NOT == FALSE this gives the following result on an empty string: $a = ""; isset( $a ) == TRUE while $a = null; isset( $a ) == FALSE; for the same story there are the == === and != !=== operators ________________________________ Von: Martin Scotta <martinsco...@gmail.com> An: Andrew Ballard <aball...@gmail.com> CC: Ralph Deffke <ralph_def...@yahoo.de>; php-gene...@lists..php.net Gesendet: Montag, den 10. August 2009, 20:40:19 Uhr Betreff: Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.) This "intelligence" is given by the laziness of the && operator. $res = a() && b(); # if a() is false then b() does not evaluate $res = a() & b(); # b() evaluates no matter a()'s result so, order matters. On Mon, Aug 10, 2009 at 3:29 PM, Andrew Ballard <aball...@gmail..com> wrote: On Mon, Aug 10, 2009 at 1:50 PM, Ralph Deffke<ralph_def...@yahoo.de> wrote: >>> this is not "intelligence" its just pure math. the '&&' says if BOTH >>> expressions are true then the whole expression is true. >>> >>> so if the first one is false, the whole is false, why checking the next one >>> in the underlaying C it would be something like this >>> { >>> if ( expression == false ) return false; >>> if ( expression == false) return false; >>> return true; >>> } >>> >>> ralph >>> ralph_def...@yahoo.de > >That's logically correct, and while PHP does implement this >>"short-circuit" logic, not all languages do. In that regard, I >>appreciate what John meant by saying it makes it look "more >>intelligent." Some languages evaluate each of the conditions to their >>respective boolean results before evaluating the logical operators. > >>Andrew > > >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php > > -- Martin Scotta