FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » A little tip
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
A little tip [message #177445] Fri, 30 March 2012 17:02 Go to next message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
Here is something I jist came across, so I am passing it on:
==========
$val= TRUE;
$val &= TRUE;
print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
print ($val == TRUE) ? "Double is true\n" : "Double is false\n";

Results in:
Triple is false
Double is true
==========

Who designed that? It is totally counter-intuitive.

--
Shelly
Re: A little tip [message #177446 is a reply to message #177445] Fri, 30 March 2012 17:20 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/30/2012 1:02 PM, Shelly wrote:
> Here is something I jist came across, so I am passing it on:
> ==========
> $val= TRUE;
> $val &= TRUE;
> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>
> Results in:
> Triple is false
> Double is true
> ==========
>
> Who designed that? It is totally counter-intuitive.
>

Yes, just another problem with PHP. After the second assignment, $val
is actually a reference to TRUE. However, a variable should not be able
to reference a constant. For instance, what would the following do?

$val &= TRUE;
$val = 3;

Are we setting TRUE to 3 (that's what a reference should do, after all).

This is why other languages don't allow references to constants.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: A little tip [message #177447 is a reply to message #177446] Fri, 30 March 2012 18:18 Go to previous messageGo to next message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
On 3/30/2012 1:20 PM, Jerry Stuckle wrote:
> On 3/30/2012 1:02 PM, Shelly wrote:
>> Here is something I jist came across, so I am passing it on:
>> ==========
>> $val= TRUE;
>> $val &= TRUE;
>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>
>> Results in:
>> Triple is false
>> Double is true
>> ==========
>>
>> Who designed that? It is totally counter-intuitive.
>>
>
> Yes, just another problem with PHP. After the second assignment, $val is
> actually a reference to TRUE. However, a variable should not be able to
> reference a constant. For instance, what would the following do?
>
> $val &= TRUE;
> $val = 3;
>
> Are we setting TRUE to 3 (that's what a reference should do, after all).
>
> This is why other languages don't allow references to constants.

Huh? How is it a reference? I wrote

$val = TRUE;

That sets TRUE as the value contained in the location specified by the
variable $val.

Then I wrote

$val &= TRUE;

which is identical to

$val = $val && TRUE;

isn't it, which should put into the location of $val the resulting value
of the logical operation of TRUE AND TRUE -- which SHOULD be TRUE.
Instead, it is something other than FALSE or ZERO, but not === to TRUE.

Your answer seems to be as if I had written

$val = &TRUE;
$val = 3;

Am I missing something here?

--
Shelly
Re: A little tip [message #177448 is a reply to message #177446] Fri, 30 March 2012 19:36 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote in news:jl4q1i$top$1(at)dont-email(dot)me:

> On 3/30/2012 1:02 PM, Shelly wrote:
>> Here is something I jist came across, so I am passing it on:
>> ==========
>> $val= TRUE;
>> $val &= TRUE;
>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>
>> Results in:
>> Triple is false
>> Double is true
>> ==========
>>
>> Who designed that? It is totally counter-intuitive.
>>
>
> Yes, just another problem with PHP. After the second assignment, $val
> is actually a reference to TRUE.

It obviously is nothing of the sort.
Re: A little tip [message #177449 is a reply to message #177447] Fri, 30 March 2012 20:19 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/30/2012 2:18 PM, Shelly wrote:
> On 3/30/2012 1:20 PM, Jerry Stuckle wrote:
>> On 3/30/2012 1:02 PM, Shelly wrote:
>>> Here is something I jist came across, so I am passing it on:
>>> ==========
>>> $val= TRUE;
>>> $val &= TRUE;
>>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>
>>> Results in:
>>> Triple is false
>>> Double is true
>>> ==========
>>>
>>> Who designed that? It is totally counter-intuitive.
>>>
>>
>> Yes, just another problem with PHP. After the second assignment, $val is
>> actually a reference to TRUE. However, a variable should not be able to
>> reference a constant. For instance, what would the following do?
>>
>> $val &= TRUE;
>> $val = 3;
>>
>> Are we setting TRUE to 3 (that's what a reference should do, after all).
>>
>> This is why other languages don't allow references to constants.
>
> Huh? How is it a reference? I wrote
>
> $val = TRUE;
>
> That sets TRUE as the value contained in the location specified by the
> variable $val.
>
> Then I wrote
>
> $val &= TRUE;
>
> which is identical to
>
> $val = $val && TRUE;
>
> isn't it, which should put into the location of $val the resulting value
> of the logical operation of TRUE AND TRUE -- which SHOULD be TRUE.
> Instead, it is something other than FALSE or ZERO, but not === to TRUE.
>
> Your answer seems to be as if I had written
>
> $val = &TRUE;
> $val = 3;
>
> Am I missing something here?
>

You're right, Shelly - it's AND instead of reference. I was mixing it
up with $val = &TRUE.

But this is a bitwise AND - which means the TRUE will be converted to an
integer 1 and the result will be an integer 1. It is non-zero, so it is
TRUE, but it is not a logical TRUE.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: A little tip [message #177450 is a reply to message #177448] Fri, 30 March 2012 20:21 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/30/2012 3:36 PM, Doug Miller wrote:
> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl4q1i$top$1(at)dont-email(dot)me:
>
>> On 3/30/2012 1:02 PM, Shelly wrote:
>>> Here is something I jist came across, so I am passing it on:
>>> ==========
>>> $val= TRUE;
>>> $val&= TRUE;
>>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>
>>> Results in:
>>> Triple is false
>>> Double is true
>>> ==========
>>>
>>> Who designed that? It is totally counter-intuitive.
>>>
>>
>> Yes, just another problem with PHP. After the second assignment, $val
>> is actually a reference to TRUE.
>
> It obviously is nothing of the sort.

And you're obviously trolling (which figures for you) and have no idea
what his problem is - or you would have answered his question.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: A little tip [message #177451 is a reply to message #177447] Fri, 30 March 2012 20:30 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
Shelly schrieb:

> $val = TRUE;

> $val &= TRUE;
>
> which is identical to
>
> $val = $val && TRUE;

No. &= is a bitwise operator while && means the logical AND operator. So
when you do $val &= TRUE, PHP is trying to do TRUE & TRUE, but since
bitwise operators only work with integers, TRUE is first coerced into
the integer 1. So the operation ends up as 1 & 1 yielding the integer 1.
Thus, $val = 1. The === operator checks the type of the operands which
are int and bool and thus not the same, while == tries to convert the
operands into something "comparable" and since they are both "truish"
the result is TRUE here.

Greetings,
Thomas


--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Re: A little tip [message #177452 is a reply to message #177450] Fri, 30 March 2012 20:52 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote in news:jl54k3$bv5$2(at)dont-email(dot)me:

> On 3/30/2012 3:36 PM, Doug Miller wrote:
>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl4q1i$top$1(at)dont-email(dot)me:
>>
>>> On 3/30/2012 1:02 PM, Shelly wrote:
>>>> Here is something I jist came across, so I am passing it on:
>>>> ==========
>>>> $val= TRUE;
>>>> $val&= TRUE;
>>>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>>
>>>> Results in:
>>>> Triple is false
>>>> Double is true
>>>> ==========
>>>>
>>>> Who designed that? It is totally counter-intuitive.
>>>>
>>>
>>> Yes, just another problem with PHP. After the second assignment, $val
>>> is actually a reference to TRUE.
>>
>> It obviously is nothing of the sort.
>
> And you're obviously trolling (which figures for you) and have no idea
> what his problem is - or you would have answered his question.
>
Typical Stuckle -- never, EVER, under any circumstances admit to being wrong.
Re: A little tip [message #177453 is a reply to message #177451] Fri, 30 March 2012 20:55 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
Thomas Mlynarczyk <thomas(at)mlynarczyk-webdesign(dot)de> wrote in news:jl554d$1s6$1
@news.albasani.net:

> Shelly schrieb:
>
>> $val = TRUE;
>
>> $val &= TRUE;
>>
>> which is identical to
>>
>> $val = $val && TRUE;
>
> No. &= is a bitwise operator while && means the logical AND operator. So
> when you do $val &= TRUE, PHP is trying to do TRUE & TRUE, but since
> bitwise operators only work with integers, TRUE is first coerced into
> the integer 1. So the operation ends up as 1 & 1 yielding the integer 1.
> Thus, $val = 1. The === operator checks the type of the operands which
> are int and bool and thus not the same, while == tries to convert the
> operands into something "comparable" and since they are both "truish"
> the result is TRUE here.

More precisely, the reason for the difference is that == means "equivalent" and === means
"identical". Since one value is integer and the other value is Boolean, they are equivalent
but not identical.
Re: A little tip [message #177454 is a reply to message #177451] Fri, 30 March 2012 20:55 Go to previous messageGo to next message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
On 3/30/2012 4:30 PM, Thomas Mlynarczyk wrote:
> Shelly schrieb:
>
>> $val = TRUE;
>
>> $val &= TRUE;
>>
>> which is identical to
>>
>> $val = $val && TRUE;
>
> No. &= is a bitwise operator while && means the logical AND operator. So
> when you do $val &= TRUE, PHP is trying to do TRUE & TRUE, but since
> bitwise operators only work with integers, TRUE is first coerced into
> the integer 1. So the operation ends up as 1 & 1 yielding the integer 1.
> Thus, $val = 1. The === operator checks the type of the operands which
> are int and bool and thus not the same, while == tries to convert the
> operands into something "comparable" and since they are both "truish"
> the result is TRUE here.
>
> Greetings,
> Thomas
>

Thank you. That makes a lot of sense. So, what I have to do if I want
to use === is to use the expanded form

$val = $val && TRUE;

Right?


--
Shelly
Re: A little tip [message #177455 is a reply to message #177454] Fri, 30 March 2012 21:07 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/30/2012 4:55 PM, Shelly wrote:
> On 3/30/2012 4:30 PM, Thomas Mlynarczyk wrote:
>> Shelly schrieb:
>>
>>> $val = TRUE;
>>
>>> $val &= TRUE;
>>>
>>> which is identical to
>>>
>>> $val = $val && TRUE;
>>
>> No. &= is a bitwise operator while && means the logical AND operator. So
>> when you do $val &= TRUE, PHP is trying to do TRUE & TRUE, but since
>> bitwise operators only work with integers, TRUE is first coerced into
>> the integer 1. So the operation ends up as 1 & 1 yielding the integer 1.
>> Thus, $val = 1. The === operator checks the type of the operands which
>> are int and bool and thus not the same, while == tries to convert the
>> operands into something "comparable" and since they are both "truish"
>> the result is TRUE here.
>>
>> Greetings,
>> Thomas
>>
>
> Thank you. That makes a lot of sense. So, what I have to do if I want to
> use === is to use the expanded form
>
> $val = $val && TRUE;
>
> Right?
>
>

Yes, that should work just fine.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: A little tip [message #177456 is a reply to message #177452] Fri, 30 March 2012 21:08 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/30/2012 4:52 PM, Doug Miller wrote:
> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl54k3$bv5$2(at)dont-email(dot)me:
>
>> On 3/30/2012 3:36 PM, Doug Miller wrote:
>>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl4q1i$top$1(at)dont-email(dot)me:
>>>
>>>> On 3/30/2012 1:02 PM, Shelly wrote:
>>>> > Here is something I jist came across, so I am passing it on:
>>>> > ==========
>>>> > $val= TRUE;
>>>> > $val&= TRUE;
>>>> > print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> > print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >
>>>> > Results in:
>>>> > Triple is false
>>>> > Double is true
>>>> > ==========
>>>> >
>>>> > Who designed that? It is totally counter-intuitive.
>>>> >
>>>>
>>>> Yes, just another problem with PHP. After the second assignment, $val
>>>> is actually a reference to TRUE.
>>>
>>> It obviously is nothing of the sort.
>>
>> And you're obviously trolling (which figures for you) and have no idea
>> what his problem is - or you would have answered his question.
>>
> Typical Stuckle -- never, EVER, under any circumstances admit to being wrong.
>

Typical Miller - can't read - or you'd already see where I corrected myself.

But then trolls never were known for their intelligence. That's why
they have to troll - otherwise they wouldn't have anything to say. And
that would be a huge blow to their egos!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: A little tip [message #177457 is a reply to message #177452] Fri, 30 March 2012 21:20 Go to previous messageGo to next message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
On 3/30/2012 4:52 PM, Doug Miller wrote:
> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl54k3$bv5$2(at)dont-email(dot)me:
>
>> On 3/30/2012 3:36 PM, Doug Miller wrote:
>>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl4q1i$top$1(at)dont-email(dot)me:
>>>
>>>> On 3/30/2012 1:02 PM, Shelly wrote:
>>>> > Here is something I jist came across, so I am passing it on:
>>>> > ==========
>>>> > $val= TRUE;
>>>> > $val&= TRUE;
>>>> > print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> > print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >
>>>> > Results in:
>>>> > Triple is false
>>>> > Double is true
>>>> > ==========
>>>> >
>>>> > Who designed that? It is totally counter-intuitive.
>>>> >
>>>>
>>>> Yes, just another problem with PHP. After the second assignment, $val
>>>> is actually a reference to TRUE.
>>>
>>> It obviously is nothing of the sort.
>>
>> And you're obviously trolling (which figures for you) and have no idea
>> what his problem is - or you would have answered his question.
>>
> Typical Stuckle -- never, EVER, under any circumstances admit to being wrong.
>

Uh, he did.

--
Shelly
Re: A little tip [message #177458 is a reply to message #177456] Fri, 30 March 2012 21:22 Go to previous messageGo to next message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
On 3/30/2012 5:08 PM, Jerry Stuckle wrote:
> On 3/30/2012 4:52 PM, Doug Miller wrote:
>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>> news:jl54k3$bv5$2(at)dont-email(dot)me:
>>
>>> On 3/30/2012 3:36 PM, Doug Miller wrote:
>>>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>>>> news:jl4q1i$top$1(at)dont-email(dot)me:
>>>>
>>>> > On 3/30/2012 1:02 PM, Shelly wrote:
>>>> >> Here is something I jist came across, so I am passing it on:
>>>> >> ==========
>>>> >> $val= TRUE;
>>>> >> $val&= TRUE;
>>>> >> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> >> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >>
>>>> >> Results in:
>>>> >> Triple is false
>>>> >> Double is true
>>>> >> ==========
>>>> >>
>>>> >> Who designed that? It is totally counter-intuitive.
>>>> >>
>>>> >
>>>> > Yes, just another problem with PHP. After the second assignment, $val
>>>> > is actually a reference to TRUE.
>>>>
>>>> It obviously is nothing of the sort.
>>>
>>> And you're obviously trolling (which figures for you) and have no idea
>>> what his problem is - or you would have answered his question.
>>>
>> Typical Stuckle -- never, EVER, under any circumstances admit to being
>> wrong.
>>
>
> Typical Miller - can't read - or you'd already see where I corrected
> myself.
>
> But then trolls never were known for their intelligence. That's why they
> have to troll - otherwise they wouldn't have anything to say. And that
> would be a huge blow to their egos!
>

Who would have thought that my passing on the group something I learned
would turn into yet another fight. Sad, but I guess no good deed goes
unpunished.

--
Shelly
Re: A little tip [message #177459 is a reply to message #177458] Fri, 30 March 2012 23:00 Go to previous messageGo to next message
Mr. B-o-B is currently offline  Mr. B-o-B
Messages: 42
Registered: April 2011
Karma: 0
Member
Shelly cried from the depths of the abyss...

> Who would have thought that my passing on the group something I learned would
> turn into yet another fight. Sad, but I guess no good deed goes unpunished.

It's pretty entertaining though!

Steps back into the shadows....
Re: A little tip [message #177460 is a reply to message #177452] Sat, 31 March 2012 03:04 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(Doug Miller)

> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote in news:jl54k3$bv5$2(at)dont-email(dot)me:
>
>> And you're obviously trolling (which figures for you) and have no idea
>> what his problem is - or you would have answered his question.
>>
> Typical Stuckle -- never, EVER, under any circumstances admit to being wrong.

| That's how trolls act. If they couldn't criticize someone, they
| wouldn't have anything to say. But their huge egos won't let them
| stay quiet.

Fits perfectly on Jerry. Guess who wrote that ...

Micha

--
http://mfesser.de/blickwinkel
Re: A little tip [message #177461 is a reply to message #177460] Sat, 31 March 2012 03:31 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/30/2012 11:04 PM, Michael Fesser wrote:
> .oO(Doug Miller)
>
>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl54k3$bv5$2(at)dont-email(dot)me:
>>
>>> And you're obviously trolling (which figures for you) and have no idea
>>> what his problem is - or you would have answered his question.
>>>
>> Typical Stuckle -- never, EVER, under any circumstances admit to being wrong.
>
> | That's how trolls act. If they couldn't criticize someone, they
> | wouldn't have anything to say. But their huge egos won't let them
> | stay quiet.
>
> Fits perfectly on Jerry. Guess who wrote that ...
>
> Micha
>

Boy, this sure brought the trolls out. Here's another one!

Now all we need are Pointed Head and TNP to make it complete...

Of course, I don't see you adding anything constructive to this
conversation. But then trolls don't.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: A little tip [message #177462 is a reply to message #177459] Sat, 31 March 2012 03:33 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 3/30/2012 4:00 PM, Mr. B-o-B wrote:
> Shelly cried from the depths of the abyss...
>
>> Who would have thought that my passing on the group something I
>> learned would turn into yet another fight. Sad, but I guess no good
>> deed goes unpunished.
>
> It's pretty entertaining though!
>
> Steps back into the shadows....
>
>
>
>

lmao, better then 'real tv'
Re: A little tip [message #177463 is a reply to message #177452] Sat, 31 March 2012 03:35 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 3/30/2012 1:52 PM, Doug Miller wrote:
> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl54k3$bv5$2(at)dont-email(dot)me:
>
>> On 3/30/2012 3:36 PM, Doug Miller wrote:
>>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl4q1i$top$1(at)dont-email(dot)me:
>>>
>>>> On 3/30/2012 1:02 PM, Shelly wrote:
>>>> > Here is something I jist came across, so I am passing it on:
>>>> > ==========
>>>> > $val= TRUE;
>>>> > $val&= TRUE;
>>>> > print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> > print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >
>>>> > Results in:
>>>> > Triple is false
>>>> > Double is true
>>>> > ==========
>>>> >
>>>> > Who designed that? It is totally counter-intuitive.
>>>> >
>>>>
>>>> Yes, just another problem with PHP. After the second assignment, $val
>>>> is actually a reference to TRUE.
>>>
>>> It obviously is nothing of the sort.
>>
>> And you're obviously trolling (which figures for you) and have no idea
>> what his problem is - or you would have answered his question.
>>
> Typical Stuckle -- never, EVER, under any circumstances admit to being wrong.
>

waits patiently for apology from Doug to Jerry since he did admit he was
wrong.
Re: A little tip [message #177464 is a reply to message #177463] Sat, 31 March 2012 03:53 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/30/2012 11:35 PM, Scott Johnson wrote:
> On 3/30/2012 1:52 PM, Doug Miller wrote:
>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>> news:jl54k3$bv5$2(at)dont-email(dot)me:
>>
>>> On 3/30/2012 3:36 PM, Doug Miller wrote:
>>>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>>>> news:jl4q1i$top$1(at)dont-email(dot)me:
>>>>
>>>> > On 3/30/2012 1:02 PM, Shelly wrote:
>>>> >> Here is something I jist came across, so I am passing it on:
>>>> >> ==========
>>>> >> $val= TRUE;
>>>> >> $val&= TRUE;
>>>> >> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> >> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >>
>>>> >> Results in:
>>>> >> Triple is false
>>>> >> Double is true
>>>> >> ==========
>>>> >>
>>>> >> Who designed that? It is totally counter-intuitive.
>>>> >>
>>>> >
>>>> > Yes, just another problem with PHP. After the second assignment, $val
>>>> > is actually a reference to TRUE.
>>>>
>>>> It obviously is nothing of the sort.
>>>
>>> And you're obviously trolling (which figures for you) and have no idea
>>> what his problem is - or you would have answered his question.
>>>
>> Typical Stuckle -- never, EVER, under any circumstances admit to being
>> wrong.
>>
>
> waits patiently for apology from Doug to Jerry since he did admit he was
> wrong.

Don't hold your breath...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: A little tip [message #177465 is a reply to message #177464] Sat, 31 March 2012 11:58 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote in news:jl5v43$lk8$1(at)dont-email(dot)me:

> On 3/30/2012 11:35 PM, Scott Johnson wrote:
>> On 3/30/2012 1:52 PM, Doug Miller wrote:
>>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>>> news:jl54k3$bv5$2(at)dont-email(dot)me:
>>>
>>>> On 3/30/2012 3:36 PM, Doug Miller wrote:
>>>> > Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>>>> > news:jl4q1i$top$1(at)dont-email(dot)me:
>>>> >
>>>> >> On 3/30/2012 1:02 PM, Shelly wrote:
>>>> >>> Here is something I jist came across, so I am passing it on:
>>>> >>> ==========
>>>> >>> $val= TRUE;
>>>> >>> $val&= TRUE;
>>>> >>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> >>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >>>
>>>> >>> Results in:
>>>> >>> Triple is false
>>>> >>> Double is true
>>>> >>> ==========
>>>> >>>
>>>> >>> Who designed that? It is totally counter-intuitive.
>>>> >>>
>>>> >>
>>>> >> Yes, just another problem with PHP. After the second assignment, $val
>>>> >> is actually a reference to TRUE.
>>>> >
>>>> > It obviously is nothing of the sort.
>>>>
>>>> And you're obviously trolling (which figures for you) and have no idea
>>>> what his problem is - or you would have answered his question.
>>>>
>>> Typical Stuckle -- never, EVER, under any circumstances admit to being
>>> wrong.
>>>
>>
>> waits patiently for apology from Doug to Jerry since he did admit he was
>> wrong.
>
> Don't hold your breath...
>
Well, here it comes. Jerry, I do apologize. I hadn't seen your other post.
Re: A little tip [message #177466 is a reply to message #177465] Sat, 31 March 2012 13:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/31/2012 7:58 AM, Doug Miller wrote:
> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in news:jl5v43$lk8$1(at)dont-email(dot)me:
>
>> On 3/30/2012 11:35 PM, Scott Johnson wrote:
>>> On 3/30/2012 1:52 PM, Doug Miller wrote:
>>>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>>>> news:jl54k3$bv5$2(at)dont-email(dot)me:
>>>>
>>>> > On 3/30/2012 3:36 PM, Doug Miller wrote:
>>>> >> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>>>> >> news:jl4q1i$top$1(at)dont-email(dot)me:
>>>> >>
>>>> >>> On 3/30/2012 1:02 PM, Shelly wrote:
>>>> >>>> Here is something I jist came across, so I am passing it on:
>>>> >>>> ==========
>>>> >>>> $val= TRUE;
>>>> >>>> $val&= TRUE;
>>>> >>>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> >>>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >>>>
>>>> >>>> Results in:
>>>> >>>> Triple is false
>>>> >>>> Double is true
>>>> >>>> ==========
>>>> >>>>
>>>> >>>> Who designed that? It is totally counter-intuitive.
>>>> >>>>
>>>> >>>
>>>> >>> Yes, just another problem with PHP. After the second assignment, $val
>>>> >>> is actually a reference to TRUE.
>>>> >>
>>>> >> It obviously is nothing of the sort.
>>>> >
>>>> > And you're obviously trolling (which figures for you) and have no idea
>>>> > what his problem is - or you would have answered his question.
>>>> >
>>>> Typical Stuckle -- never, EVER, under any circumstances admit to being
>>>> wrong.
>>>>
>>>
>>> waits patiently for apology from Doug to Jerry since he did admit he was
>>> wrong.
>>
>> Don't hold your breath...
>>
> Well, here it comes. Jerry, I do apologize. I hadn't seen your other post.

Thank you, Doug. I appreciate the apology.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: A little tip [message #177467 is a reply to message #177454] Sat, 31 March 2012 14:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/30/2012 4:55 PM, Shelly wrote:
> On 3/30/2012 4:30 PM, Thomas Mlynarczyk wrote:
>> Shelly schrieb:
>>
>>> $val = TRUE;
>>
>>> $val &= TRUE;
>>>
>>> which is identical to
>>>
>>> $val = $val && TRUE;
>>
>> No. &= is a bitwise operator while && means the logical AND operator. So
>> when you do $val &= TRUE, PHP is trying to do TRUE & TRUE, but since
>> bitwise operators only work with integers, TRUE is first coerced into
>> the integer 1. So the operation ends up as 1 & 1 yielding the integer 1.
>> Thus, $val = 1. The === operator checks the type of the operands which
>> are int and bool and thus not the same, while == tries to convert the
>> operands into something "comparable" and since they are both "truish"
>> the result is TRUE here.
>>
>> Greetings,
>> Thomas
>>
>
> Thank you. That makes a lot of sense. So, what I have to do if I want to
> use === is to use the expanded form
>
> $val = $val && TRUE;
>
> Right?
>
>

I should also add that you need to be careful and use the correct
operator. For instance, 2 & TRUE is false, while 2 && TRUE is true.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: A little tip [message #177468 is a reply to message #177467] Sat, 31 March 2012 15:27 Go to previous messageGo to next message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
On 3/31/2012 10:05 AM, Jerry Stuckle wrote:
> On 3/30/2012 4:55 PM, Shelly wrote:
>> On 3/30/2012 4:30 PM, Thomas Mlynarczyk wrote:
>>> Shelly schrieb:
>>>
>>>> $val = TRUE;
>>>
>>>> $val &= TRUE;
>>>>
>>>> which is identical to
>>>>
>>>> $val = $val && TRUE;
>>>
>>> No. &= is a bitwise operator while && means the logical AND operator. So
>>> when you do $val &= TRUE, PHP is trying to do TRUE & TRUE, but since
>>> bitwise operators only work with integers, TRUE is first coerced into
>>> the integer 1. So the operation ends up as 1 & 1 yielding the integer 1.
>>> Thus, $val = 1. The === operator checks the type of the operands which
>>> are int and bool and thus not the same, while == tries to convert the
>>> operands into something "comparable" and since they are both "truish"
>>> the result is TRUE here.
>>>
>>> Greetings,
>>> Thomas
>>>
>>
>> Thank you. That makes a lot of sense. So, what I have to do if I want to
>> use === is to use the expanded form
>>
>> $val = $val && TRUE;
>>
>> Right?
>>
>>
>
> I should also add that you need to be careful and use the correct
> operator. For instance, 2 & TRUE is false, while 2 && TRUE is true.
>

Thanks. All my validation routines return either TRUE or FALSe. I have
a flag that repetitively goes something like this after initializing
$theFlag to TRUE:

$theFlag = $theFlag && validation_routine_call(arguments);

for each of the many validation routines.

At the end I do something if $theFlag === TRUE, and don't if not.

What I had been doing, incorrectly, (which led me to start this thread) was:

$theFlag &= validation_routine_call(arguments);

--
Shelly
Re: A little tip [message #177481 is a reply to message #177445] Mon, 02 April 2012 07:42 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 30/03/2012 19:02, Shelly escribió/wrote:
> Here is something I jist came across, so I am passing it on:
> ==========
> $val= TRUE;
> $val &= TRUE;
> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>
> Results in:
> Triple is false
> Double is true
> ==========
>
> Who designed that? It is totally counter-intuitive.

When trying to understand these subtleties, I find var_dump() more
useful than plain echos. In this case:

$val= TRUE;
var_dump($val);
$val &= TRUE;
var_dump($val);

.... prints:

bool(true)
int(1)

.... which makes the result of loose and strict comparisons obvious.



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: A little tip [message #177482 is a reply to message #177481] Mon, 02 April 2012 08:22 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 02.04.2012 09:42, schrieb "Álvaro G. Vicario":
> El 30/03/2012 19:02, Shelly escribió/wrote:
>> Here is something I jist came across, so I am passing it on:
>> ==========
>> $val= TRUE;
>> $val &= TRUE;
>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>
>> Results in:
>> Triple is false
>> Double is true
>> ==========
>>
>> Who designed that? It is totally counter-intuitive.
>
> When trying to understand these subtleties, I find var_dump() more useful than plain
> echos. In this case:
>
> $val= TRUE;
> var_dump($val);
> $val &= TRUE;
> var_dump($val);
>
> ... prints:
>
> bool(true)
> int(1)
>
> ... which makes the result of loose and strict comparisons obvious.
>

Yes, and then he could print http://de2.php.net/manual/en/types.comparisons.php and
nail it to the monitor.

/Str.
Re: A little tip [message #177488 is a reply to message #177482] Mon, 02 April 2012 12:15 Go to previous messageGo to next message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
On 4/2/2012 4:22 AM, M. Strobel wrote:
> Am 02.04.2012 09:42, schrieb "Álvaro G. Vicario":
>> El 30/03/2012 19:02, Shelly escribió/wrote:
>>> Here is something I jist came across, so I am passing it on:
>>> ==========
>>> $val= TRUE;
>>> $val&= TRUE;
>>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>
>>> Results in:
>>> Triple is false
>>> Double is true
>>> ==========
>>>
>>> Who designed that? It is totally counter-intuitive.
>>
>> When trying to understand these subtleties, I find var_dump() more useful than plain
>> echos. In this case:
>>
>> $val= TRUE;
>> var_dump($val);
>> $val&= TRUE;
>> var_dump($val);
>>
>> ... prints:
>>
>> bool(true)
>> int(1)
>>
>> ... which makes the result of loose and strict comparisons obvious.
>>
>
> Yes, and then he could print http://de2.php.net/manual/en/types.comparisons.php and
> nail it to the monitor.

Now was that really necessary -- or do you just get a rise out of
insulting people who try to be helpful?

--
Shelly
Re: A little tip [message #177490 is a reply to message #177488] Mon, 02 April 2012 12:27 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 02.04.2012 14:15, schrieb Shelly:
> On 4/2/2012 4:22 AM, M. Strobel wrote:
>> Am 02.04.2012 09:42, schrieb "Álvaro G. Vicario":
>>> El 30/03/2012 19:02, Shelly escribió/wrote:
>>>> Here is something I jist came across, so I am passing it on:
>>>> ==========
>>>> $val= TRUE;
>>>> $val&= TRUE;
>>>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>>
>>>> Results in:
>>>> Triple is false
>>>> Double is true
>>>> ==========
>>>>
>>>> Who designed that? It is totally counter-intuitive.
>>>
>>> When trying to understand these subtleties, I find var_dump() more useful than plain
>>> echos. In this case:
>>>
>>> $val= TRUE;
>>> var_dump($val);
>>> $val&= TRUE;
>>> var_dump($val);
>>>
>>> ... prints:
>>>
>>> bool(true)
>>> int(1)
>>>
>>> ... which makes the result of loose and strict comparisons obvious.
>>>
>>
>> Yes, and then he could print http://de2.php.net/manual/en/types.comparisons.php and
>> nail it to the monitor.
>
> Now was that really necessary -- or do you just get a rise out of insulting people
> who try to be helpful?
>

Insulting? The monitor, because I told you to nail the paper on it?

And then I said "he", which went to the original poster. That is you.

I know your only error was using the wrong operator, but when it comes to loose
comparison the link I gave is *the* reference. There are far more people reading here
than writing who stumble upon this by G____e and can find complete solutions.

/Str.
Re: A little tip [message #177492 is a reply to message #177490] Mon, 02 April 2012 13:40 Go to previous messageGo to next message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
On 4/2/2012 8:27 AM, M. Strobel wrote:
> Am 02.04.2012 14:15, schrieb Shelly:
>> On 4/2/2012 4:22 AM, M. Strobel wrote:
>>> Am 02.04.2012 09:42, schrieb "Álvaro G. Vicario":
>>>> El 30/03/2012 19:02, Shelly escribió/wrote:
>>>> > Here is something I jist came across, so I am passing it on:
>>>> > ==========
>>>> > $val= TRUE;
>>>> > $val&= TRUE;
>>>> > print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> > print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >
>>>> > Results in:
>>>> > Triple is false
>>>> > Double is true
>>>> > ==========
>>>> >
>>>> > Who designed that? It is totally counter-intuitive.
>>>>
>>>> When trying to understand these subtleties, I find var_dump() more useful than plain
>>>> echos. In this case:
>>>>
>>>> $val= TRUE;
>>>> var_dump($val);
>>>> $val&= TRUE;
>>>> var_dump($val);
>>>>
>>>> ... prints:
>>>>
>>>> bool(true)
>>>> int(1)
>>>>
>>>> ... which makes the result of loose and strict comparisons obvious.
>>>>
>>>
>>> Yes, and then he could print http://de2.php.net/manual/en/types.comparisons.php and
>>> nail it to the monitor.
>>
>> Now was that really necessary -- or do you just get a rise out of insulting people
>> who try to be helpful?
>>
>
> Insulting? The monitor, because I told you to nail the paper on it?

Yes. A non-insulting way or responding, while giving the information,
would have been

"Yes, the complete information can be found at
http://de2.php.net/manual/en/types.comparisons.php"

> And then I said "he", which went to the original poster. That is you.

--
Shelly
Re: A little tip [message #177501 is a reply to message #177492] Mon, 02 April 2012 21:43 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 02.04.2012 15:40, schrieb Shelly:
> On 4/2/2012 8:27 AM, M. Strobel wrote:
>> Am 02.04.2012 14:15, schrieb Shelly:
>>> On 4/2/2012 4:22 AM, M. Strobel wrote:
>>>> Am 02.04.2012 09:42, schrieb "Álvaro G. Vicario":
>>>> > El 30/03/2012 19:02, Shelly escribió/wrote:
>>>> >> Here is something I jist came across, so I am passing it on:
>>>> >> ==========
>>>> >> $val= TRUE;
>>>> >> $val&= TRUE;
>>>> >> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> >> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >>
>>>> >> Results in:
>>>> >> Triple is false
>>>> >> Double is true
>>>> >> ==========
>>>> >>
>>>> >> Who designed that? It is totally counter-intuitive.
>>>> >
>>>> > When trying to understand these subtleties, I find var_dump() more useful than
>>>> > plain
>>>> > echos. In this case:
>>>> >
>>>> > $val= TRUE;
>>>> > var_dump($val);
>>>> > $val&= TRUE;
>>>> > var_dump($val);
>>>> >
>>>> > ... prints:
>>>> >
>>>> > bool(true)
>>>> > int(1)
>>>> >
>>>> > ... which makes the result of loose and strict comparisons obvious.
>>>> >
>>>>
>>>> Yes, and then he could print http://de2.php.net/manual/en/types.comparisons.php and
>>>> nail it to the monitor.
>>>
>>> Now was that really necessary -- or do you just get a rise out of insulting people
>>> who try to be helpful?
>>>
>>
>> Insulting? The monitor, because I told you to nail the paper on it?
>
> Yes. A non-insulting way or responding, while giving the information, would have been
>
> "Yes, the complete information can be found at
> http://de2.php.net/manual/en/types.comparisons.php"
>

If you take words like that, have fun on Usenet.

/Str.
Re: A little tip [message #177511 is a reply to message #177454] Tue, 03 April 2012 13:52 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Shelly wrote:

> On 3/30/2012 4:30 PM, Thomas Mlynarczyk wrote:
>> Shelly schrieb:
>>> $val = TRUE;
>>
>>> $val &= TRUE;
>>>
>>> which is identical to
>>>
>>> $val = $val && TRUE;
>>
>> No. &= is a bitwise operator while && means the logical AND operator. So
>> when you do $val &= TRUE, PHP is trying to do TRUE & TRUE, but since
>> bitwise operators only work with integers, TRUE is first coerced into
>> the integer 1. So the operation ends up as 1 & 1 yielding the integer 1.
>> Thus, $val = 1. The === operator checks the type of the operands which
>> are int and bool and thus not the same, while == tries to convert the
>> operands into something "comparable" and since they are both "truish"
>> the result is TRUE here.
>
> Thank you. That makes a lot of sense. So, what I have to do if I want
> to use === is to use the expanded form
>
> $val = $val && TRUE;

You keep missing the point. That is _not_ "the expanded form" of anything.
`&=' and `&&' are *different* operators; the first one is a *bitwise*
operator, the second is a *logical* (boolean) one.

In that sense,

x = x & 1;

is "the expanded form" of

x &= 1;

<http://php.net/operators>

Please do not full-quote.


PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
Re: A little tip [message #177512 is a reply to message #177457] Tue, 03 April 2012 13:56 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Shelly wrote:

> On 3/30/2012 4:52 PM, Doug Miller wrote:
>> Jerry Stuckle […]:
>>> On 3/30/2012 3:36 PM, Doug Miller wrote:
>>>> Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>>>> news:jl4q1i$top$1(at)dont-email(dot)me:
>>>>
>>>> > On 3/30/2012 1:02 PM, Shelly wrote:
>>>> >> Here is something I jist came across, so I am passing it on:
>>>> >> ==========
>>>> >> $val= TRUE;
>>>> >> $val&= TRUE;
>>>> >> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> >> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >>
>>>> >> Results in:
>>>> >> Triple is false
>>>> >> Double is true
>>>> >> ==========
>>>> >>
>>>> >> Who designed that? It is totally counter-intuitive.
>>>> >
>>>> > Yes, just another problem with PHP. After the second assignment, $val
>>>> > is actually a reference to TRUE.
>>> It obviously is nothing of the sort.
>>>
>>> And you're obviously trolling (which figures for you) and have no idea
>>> what his problem is - or you would have answered his question.
>>>
>> Typical Stuckle -- never, EVER, under any circumstances admit to being
>> wrong.
>
> Uh, he did.

Where?


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
Re: A little tip [message #177513 is a reply to message #177511] Tue, 03 April 2012 14:20 Go to previous messageGo to next message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
On 4/3/2012 9:52 AM, Thomas 'PointedEars' Lahn wrote:
> You keep missing the point. That is_not_ "the expanded form" of anything.
> `&=' and `&&' are*different* operators; the first one is a*bitwise*
> operator, the second is a*logical* (boolean) one.

I know. I meant I couldn't use a form where the original is not
included on the RHS. I understand the difference and always did. I
just didn't realize that &= what the shortened form of "&" and not "&&".

--
Shelly
Re: A little tip [message #177514 is a reply to message #177512] Tue, 03 April 2012 14:20 Go to previous message
Shelly[1] is currently offline  Shelly[1]
Messages: 16
Registered: March 2012
Karma: 0
Junior Member
On 4/3/2012 9:56 AM, Thomas 'PointedEars' Lahn wrote:
> Shelly wrote:
>
>> On 3/30/2012 4:52 PM, Doug Miller wrote:
>>> Jerry Stuckle […]:
>>>> On 3/30/2012 3:36 PM, Doug Miller wrote:
>>>> > Jerry Stuckle<jstucklex(at)attglobal(dot)net> wrote in
>>>> > news:jl4q1i$top$1(at)dont-email(dot)me:
>>>> >
>>>> >> On 3/30/2012 1:02 PM, Shelly wrote:
>>>> >>> Here is something I jist came across, so I am passing it on:
>>>> >>> ==========
>>>> >>> $val= TRUE;
>>>> >>> $val&= TRUE;
>>>> >>> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
>>>> >>> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>>>> >>>
>>>> >>> Results in:
>>>> >>> Triple is false
>>>> >>> Double is true
>>>> >>> ==========
>>>> >>>
>>>> >>> Who designed that? It is totally counter-intuitive.
>>>> >>
>>>> >> Yes, just another problem with PHP. After the second assignment, $val
>>>> >> is actually a reference to TRUE.
>>>> It obviously is nothing of the sort.
>>>>
>>>> And you're obviously trolling (which figures for you) and have no idea
>>>> what his problem is - or you would have answered his question.
>>>>
>>> Typical Stuckle -- never, EVER, under any circumstances admit to being
>>> wrong.
>>
>> Uh, he did.
>
> Where?

His second reply. The one after I pointed out to him how he has misread
what I wrote.
>
>
> PointedEars


--
Shelly
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: session variable doesn't appear in side bar
Next Topic: Doubt regarding an array of references...
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 02:30:34 GMT 2024

Total time taken to generate the page: 0.02714 seconds