Re: [PHP] Boolean Assignment Operator

2009-02-06 Thread Thodoris
2009/2/2 Gavin Hodge Hi, I'm fairly new to PHP, having migrated from the Java / C# world. I wrote some code similar to the following: $success = true; $success &= operation1(); $success &= operation2(); if ($success === true) { operation3(); // depends on 1 and 2 being successful }

Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Nitsan Bin-Nun
It actually will return FATAL ERROR or something like that since you didn't echo'ed variables or string ;) On Mon, Feb 2, 2009 at 3:03 PM, Edmund Hertle wrote: > 2009/2/2 Gavin Hodge > > > Hi, > > > > I'm fairly new to PHP, having migrated from the Java / C# world. > > > > I wrote some code sim

RE: [PHP] Boolean Assignment Operator

2009-02-02 Thread Steven Buehler
> -Original Message- > From: farn...@googlemail.com [mailto:farn...@googlemail.com] On Behalf > Of Edmund Hertle > Sent: Monday, February 02, 2009 7:03 AM > To: Gavin Hodge > Cc: php-general@lists.php.net > Subject: Re: [PHP] Boolean Assignment Operator >

Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Gavin Hodge
Wow, thanks for the quick replies! I hadn't realised that & was purely a bitwise operator. In the strongly-typed Java world, & works as a non-lazy (exhaustive?) boolean operator so it has to return a boolean for boolean inputs. Thats the difference here, and Robert got it in one. Gavin. PS. A c

Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Edmund Hertle
2009/2/2 Robert Cummings > On Tue, 2009-02-03 at 00:07 +1100, Gavin Hodge wrote: > > In Java / C# / C, > > $bool &= $anotherBool; > > is shorthand for > > $bool = $bool & $anotherBool; > > > > So &= forces a reference assignment? > > No, =& forces reference assignment. &= works as you have writte

Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Eric Butera
On Mon, Feb 2, 2009 at 7:49 AM, Gavin Hodge wrote: > Hi, > > I'm fairly new to PHP, having migrated from the Java / C# world. > > I wrote some code similar to the following: > > $success = true; > $success &= operation1(); > $success &= operation2(); > > if ($success === true) { >operation3();

Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Robert Cummings
On Tue, 2009-02-03 at 00:07 +1100, Gavin Hodge wrote: > In Java / C# / C, > $bool &= $anotherBool; > is shorthand for > $bool = $bool & $anotherBool; > > So &= forces a reference assignment? No, =& forces reference assignment. &= works as you have written. Cheers, Rob. -- http://www.interjinn.c

Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Robert Cummings
On Mon, 2009-02-02 at 23:49 +1100, Gavin Hodge wrote: > Hi, > > I'm fairly new to PHP, having migrated from the Java / C# world. > > I wrote some code similar to the following: > > $success = true; > $success &= operation1(); > $success &= operation2(); > > if ($success === true) { > operat

Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Gavin Hodge
In Java / C# / C, $bool &= $anotherBool; is shorthand for $bool = $bool & $anotherBool; So &= forces a reference assignment? On Tue, Feb 3, 2009 at 12:03 AM, Edmund Hertle wrote: > 2009/2/2 Gavin Hodge >> >> Hi, >> >> I'm fairly new to PHP, having migrated from the Java / C# world. >> >> I wrot

Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Edmund Hertle
2009/2/2 Gavin Hodge > Hi, > > I'm fairly new to PHP, having migrated from the Java / C# world. > > I wrote some code similar to the following: > > $success = true; > $success &= operation1(); > $success &= operation2(); > > if ($success === true) { >operation3(); // depends on 1 and 2 being

[PHP] Boolean Assignment Operator

2009-02-02 Thread Gavin Hodge
Hi, I'm fairly new to PHP, having migrated from the Java / C# world. I wrote some code similar to the following: $success = true; $success &= operation1(); $success &= operation2(); if ($success === true) { operation3(); // depends on 1 and 2 being successful } This didn't work as expected