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

$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

$a = null;
isset( $a ) == FALSE;

for the same story there are the

Von: Martin Scotta <>
An: Andrew Ballard <>
CC: Ralph Deffke <>;
Gesendet: Montag, den 10. August 2009, 20:40:19 Uhr
Betreff: Re: [PHP] reason for a "Notice:.." on one site but not another? (Same  

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 <> wrote:

On Mon, Aug 10, 2009 at 1:50 PM, Ralph Deffke<> 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
>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.
>>PHP General Mailing List (
>>To unsubscribe, visit:

Martin Scotta


Reply via email to