Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #12657 > unrolled thread

include capturing wrong value

Started byrichard <noreply@example.com>
First post2014-01-14 11:56 -0500
Last post2014-01-14 21:20 +0000
Articles 11 — 7 participants

Back to article view | Back to comp.lang.php


Contents

  include capturing wrong value richard <noreply@example.com> - 2014-01-14 11:56 -0500
    Re: include capturing wrong value Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-14 17:23 +0000
      Re: include capturing wrong value richard <noreply@example.com> - 2014-01-14 12:50 -0500
        Re: include capturing wrong value Christoph Michael Becker <cmbecker69@arcor.de> - 2014-01-14 19:07 +0100
        Re: include capturing wrong value Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-01-14 10:10 -0800
        Re: include capturing wrong value Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-14 18:25 +0000
        Re: include capturing wrong value Arno Welzel <usenet@arnowelzel.de> - 2014-01-23 18:50 +0100
          Re: include capturing wrong value Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-23 18:05 +0000
            Re: include capturing wrong value "Peter H. Coffin" <hellsop@ninehells.com> - 2014-01-23 15:56 -0600
            Re: include capturing wrong value Arno Welzel <usenet@arnowelzel.de> - 2014-01-25 10:20 +0100
    Re: include capturing wrong value Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-01-14 21:20 +0000

#12657 — include capturing wrong value

Fromrichard <noreply@example.com>
Date2014-01-14 11:56 -0500
Subjectinclude capturing wrong value
Message-ID<18dy94v4tv51n.1f3ltkhc8door$.dlg@40tude.net>
$go=$_GET['a'];
if(empty($go)){$go=0;}

if ($go>=60 and $go<=69) { include
"http://mroldies.net/songs/19".$go.".html";}
if ($go>="A" and $go<="Z") <<<<<< 
{ include"http://mroldies.net/songs/".$go.".html";}

if ($go==2){include "http://mroldies.net/radio/24hours.php";}
if ($go==1){include"http://mroldies.net/test/index2.php";}
if ($go==0){include "http://mroldies.net/home1.php";}

Using this code I now get a warning stating that the file can't be found.
"Zero" returns true for the marked line.
I can see where that would be the case using or.
But not AND!
Since "Zero" is less than "A" then the condition returns false.
Why do I not get the same warning from the first match test?
"zero" is less than 69 so that should return true.

[toc] | [next] | [standalone]


#12658

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-01-14 17:23 +0000
Message-ID<lb3rqd$adc$1@dont-email.me>
In reply to#12657
On Tue, 14 Jan 2014 11:56:16 -0500, richard wrote:

> $go=$_GET['a'];
> if(empty($go)){$go=0;}
> 
> if ($go>=60 and $go<=69) { include
> "http://mroldies.net/songs/19".$go.".html";}
> if ($go>="A" and $go<="Z") <<<<<<
> { include"http://mroldies.net/songs/".$go.".html";}
> 
> if ($go==2){include "http://mroldies.net/radio/24hours.php";}
> if ($go==1){include"http://mroldies.net/test/index2.php";}
> if ($go==0){include "http://mroldies.net/home1.php";}
> 
> Using this code I now get a warning stating that the file can't be
> found.
> "Zero" returns true for the marked line.
> I can see where that would be the case using or.
> But not AND!

This is your fucked up comprehension of comparison.

> Since "Zero" is less than "A" then the condition returns false.

You are making an incorrect assumption about the way a string variable is 
compared to the number 0. You are not comparing the string "Zero" with 
the strings "A" and "Z", you are comparing the number 0 with the strings 
"A" and "Z". If you check the relevant php documentation, you will 
understand that the behaviour here is exactly as it is documented to be.

> Why do I not get the same warning from the first match test?
> "zero" is less than 69 so that should return true.

You are not comparing the string "zero", you are comparing the number 0. 
You are only considering part of the test you are discussing in your 
above statements. You need to consider the whole test. The behaviour 
appears on inspection to be correct.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#12659

Fromrichard <noreply@example.com>
Date2014-01-14 12:50 -0500
Message-ID<4ch32eyxvwzd.o6ojwp3x5vt7$.dlg@40tude.net>
In reply to#12658
On Tue, 14 Jan 2014 17:23:25 +0000 (UTC), Denis McMahon wrote:

> On Tue, 14 Jan 2014 11:56:16 -0500, richard wrote:
> 
>> $go=$_GET['a'];
>> if(empty($go)){$go=0;}
>> 
>> if ($go>=60 and $go<=69) { include
>> "http://mroldies.net/songs/19".$go.".html";}
>> if ($go>="A" and $go<="Z") <<<<<<
>> { include"http://mroldies.net/songs/".$go.".html";}
>> 
>> if ($go==2){include "http://mroldies.net/radio/24hours.php";}
>> if ($go==1){include"http://mroldies.net/test/index2.php";}
>> if ($go==0){include "http://mroldies.net/home1.php";}
>> 
>> Using this code I now get a warning stating that the file can't be
>> found.
>> "Zero" returns true for the marked line.
>> I can see where that would be the case using or.
>> But not AND!
> 
> This is your fucked up comprehension of comparison.
> 
>> Since "Zero" is less than "A" then the condition returns false.
> 
> You are making an incorrect assumption about the way a string variable is 
> compared to the number 0. You are not comparing the string "Zero" with 
> the strings "A" and "Z", you are comparing the number 0 with the strings 
> "A" and "Z". If you check the relevant php documentation, you will 
> understand that the behaviour here is exactly as it is documented to be.
> 
>> Why do I not get the same warning from the first match test?
>> "zero" is less than 69 so that should return true.
> 
> You are not comparing the string "zero", you are comparing the number 0. 
> You are only considering part of the test you are discussing in your 
> above statements. You need to consider the whole test. The behaviour 
> appears on inspection to be correct.

Point noted and understood.
Still, "AND" is the key. not "OR".
Both must be true to return true.
Since 0 (zero as string) ls not greater than "A" the condition should
return false.

[toc] | [prev] | [next] | [standalone]


#12660

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-01-14 19:07 +0100
Message-ID<52d57cd8$0$6570$9b4e6d93@newsspool4.arcor-online.net>
In reply to#12659
richard wrote:

> On Tue, 14 Jan 2014 17:23:25 +0000 (UTC), Denis McMahon wrote:
> 
>> On Tue, 14 Jan 2014 11:56:16 -0500, richard wrote:
>>
>>> $go=$_GET['a'];
>>> if(empty($go)){$go=0;}
>>>
> Point noted and understood.
> Still, "AND" is the key. not "OR".
> Both must be true to return true.
> Since 0 (zero as string) ls not greater than "A" the condition should
> return false.

You do not compare '0', but rather 0, as a simple var_dump($go) would
show.  This is because empty('0') === true.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#12661

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2014-01-14 10:10 -0800
Message-ID<64fBu.271440$kN2.196566@fx19.iad>
In reply to#12659
On 1/14/14 9:50 AM, richard wrote:
> On Tue, 14 Jan 2014 17:23:25 +0000 (UTC), Denis McMahon wrote:
>
>> On Tue, 14 Jan 2014 11:56:16 -0500, richard wrote:
>>
>>> $go=$_GET['a'];
>>> if(empty($go)){$go=0;}
>>>
>>> if ($go>=60 and $go<=69) { include
>>> "http://mroldies.net/songs/19".$go.".html";}
>>> if ($go>="A" and $go<="Z") <<<<<<
>>> { include"http://mroldies.net/songs/".$go.".html";}
>>>
>>> if ($go==2){include "http://mroldies.net/radio/24hours.php";}
>>> if ($go==1){include"http://mroldies.net/test/index2.php";}
>>> if ($go==0){include "http://mroldies.net/home1.php";}
>>>
>>> Using this code I now get a warning stating that the file can't be
>>> found.
>>> "Zero" returns true for the marked line.
>>> I can see where that would be the case using or.
>>> But not AND!
>>
>> This is your fucked up comprehension of comparison.
>>
>>> Since "Zero" is less than "A" then the condition returns false.
>>
>> You are making an incorrect assumption about the way a string variable is
>> compared to the number 0. You are not comparing the string "Zero" with
>> the strings "A" and "Z", you are comparing the number 0 with the strings
>> "A" and "Z". If you check the relevant php documentation, you will
>> understand that the behaviour here is exactly as it is documented to be.
>>
>>> Why do I not get the same warning from the first match test?
>>> "zero" is less than 69 so that should return true.
>>
>> You are not comparing the string "zero", you are comparing the number 0.
>> You are only considering part of the test you are discussing in your
>> above statements. You need to consider the whole test. The behaviour
>> appears on inspection to be correct.
>
> Point noted and understood.
> Still, "AND" is the key. not "OR".
> Both must be true to return true.
> Since 0 (zero as string) ls not greater than "A" the condition should
> return false.
>

comparing a 0 to a string is always going to be true, regardless of 
direction or string.

0<='A' is true
0>='Z' is true
0>='A' is true


However, what you *can* do is this:
if (is_string($go) && strlen($go)===1 && ctype_alpha($go)) 
{include"http://mroldies.net/songs/".$go.".html";}

[toc] | [prev] | [next] | [standalone]


#12662

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-01-14 18:25 +0000
Message-ID<lb3ve3$adc$3@dont-email.me>
In reply to#12659
On Tue, 14 Jan 2014 12:50:18 -0500, richard wrote:

> On Tue, 14 Jan 2014 17:23:25 +0000 (UTC), Denis McMahon wrote:
> 
>> On Tue, 14 Jan 2014 11:56:16 -0500, richard wrote:
>> 
>>> $go=$_GET['a'];
>>> if(empty($go)){$go=0;}
>>> 
>>> if ($go>=60 and $go<=69) { include
>>> "http://mroldies.net/songs/19".$go.".html";}
>>> if ($go>="A" and $go<="Z") <<<<<<
>>> { include"http://mroldies.net/songs/".$go.".html";}
>>> 
>>> if ($go==2){include "http://mroldies.net/radio/24hours.php";}
>>> if ($go==1){include"http://mroldies.net/test/index2.php";}
>>> if ($go==0){include "http://mroldies.net/home1.php";}
>>> 
>>> Using this code I now get a warning stating that the file can't be
>>> found.
>>> "Zero" returns true for the marked line.
>>> I can see where that would be the case using or.
>>> But not AND!
>> 
>> This is your fucked up comprehension of comparison.
>> 
>>> Since "Zero" is less than "A" then the condition returns false.
>> 
>> You are making an incorrect assumption about the way a string variable
>> is compared to the number 0. You are not comparing the string "Zero"
>> with the strings "A" and "Z", you are comparing the number 0 with the
>> strings "A" and "Z". If you check the relevant php documentation, you
>> will understand that the behaviour here is exactly as it is documented
>> to be.
>> 
>>> Why do I not get the same warning from the first match test? "zero" is
>>> less than 69 so that should return true.
>> 
>> You are not comparing the string "zero", you are comparing the number
>> 0. You are only considering part of the test you are discussing in your
>> above statements. You need to consider the whole test. The behaviour
>> appears on inspection to be correct.
> 
> Point noted and understood.
> Still, "AND" is the key. not "OR".
> Both must be true to return true.
> Since 0 (zero as string) ls not greater than "A" the condition should
> return false.

Look again at this line:

if(empty($go)){$go=0;}

That doesn't assign zero as string, it assigns zero as number.

As I have already said, the result is according to the documentation for 
the number vs string comparison that you are carrying out!

You clearly HAVE NOT understood what you have just claimed that you 
understood!

Hint - both *ARE* true.

0 >= "A" evaluates to true
0 <= "Z" evaluates to true

hence

0 >= "A" and 0 <= "Z" evaluates to true

See: http://www.php.net/manual/en/types.comparisons.php

I'm sure you'll spectacularly fail to comprehend what the tables on that 
page show, but they are nonetheless the appropriate reference.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#12706

FromArno Welzel <usenet@arnowelzel.de>
Date2014-01-23 18:50 +0100
Message-ID<52E15659.7080203@arnowelzel.de>
In reply to#12659
richard, 2014-01-14 18:50:

> On Tue, 14 Jan 2014 17:23:25 +0000 (UTC), Denis McMahon wrote:
> 
>> On Tue, 14 Jan 2014 11:56:16 -0500, richard wrote:
>>
>>> $go=$_GET['a'];
>>> if(empty($go)){$go=0;}
>>>
>>> if ($go>=60 and $go<=69) { include
>>> "http://mroldies.net/songs/19".$go.".html";}
>>> if ($go>="A" and $go<="Z") <<<<<<
[...]
>> You are not comparing the string "zero", you are comparing the number 0. 
>> You are only considering part of the test you are discussing in your 
>> above statements. You need to consider the whole test. The behaviour 
>> appears on inspection to be correct.
> 
> Point noted and understood.
> Still, "AND" is the key. not "OR".
> Both must be true to return true.
> Since 0 (zero as string) ls not greater than "A" the condition should
> return false.

But your comparison is not "greater than" - it is "greater or equal than":

if($go>="A" and $go<="Z")

if $go is 0 (and not "0"!) - then the condition perfectly matches - 0 is
greater or *equal* than 0 and also less or *equal* than 0.


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de

[toc] | [prev] | [next] | [standalone]


#12707

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-01-23 18:05 +0000
Message-ID<lbrlkl$dl1$1@dont-email.me>
In reply to#12706
On Thu, 23 Jan 2014 18:50:17 +0100, Arno Welzel wrote:

> richard, 2014-01-14 18:50:
> 
>> On Tue, 14 Jan 2014 17:23:25 +0000 (UTC), Denis McMahon wrote:
>> 
>>> On Tue, 14 Jan 2014 11:56:16 -0500, richard wrote:
>>>
>>>> $go=$_GET['a'];
>>>> if(empty($go)){$go=0;}
>>>>
>>>> if ($go>=60 and $go<=69) { include
>>>> "http://mroldies.net/songs/19".$go.".html";}
>>>> if ($go>="A" and $go<="Z") <<<<<<
> [...]
>>> You are not comparing the string "zero", you are comparing the number
>>> 0.
>>> You are only considering part of the test you are discussing in your
>>> above statements. You need to consider the whole test. The behaviour
>>> appears on inspection to be correct.
>> 
>> Point noted and understood.
>> Still, "AND" is the key. not "OR".
>> Both must be true to return true.
>> Since 0 (zero as string) ls not greater than "A" the condition should
>> return false.
> 
> But your comparison is not "greater than" - it is "greater or equal
> than":
> 
> if($go>="A" and $go<="Z")
> 
> if $go is 0 (and not "0"!) - then the condition perfectly matches - 0 is
> greater or *equal* than 0 and also less or *equal* than 0.

Arno, remember that one of the rules of dealing with richard is that he 
never has a more fucked up understanding of something than when he thinks 
he understands it.

What he doesn't understand is that:

1) the numeric value 0 is falsey

2) the string value "any string" is falsey

3) the string value "any other string" is falsey

( 0 >= "any string" ) -> ( falsey == falsey ) -> true

( 0 <= "any other string" ) -> ( falsey == falsey ) -> true

and of course:

( true and true ) -> true

Which is why, when his $_GET['a'] has no data, and he then assigns the 
value 0 to the variable $go, the test:

($go>="A" and $go<="Z")

is interpreted as:

( 0 >= "any string" and 0 <= "any other string" )

is interpreted as:

( false >= false and false <= false )

is interpreted as:

( false == false and false == false )

is interpreted as:

( true and true )

and is thus true.

And even now that I have written the whole damn sequence out, he'll still 
fail to comprehend it and manage to make the same fuck up next week / 
month / year / decade for as long as he continues trying to code his 
website.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#12708

From"Peter H. Coffin" <hellsop@ninehells.com>
Date2014-01-23 15:56 -0600
Message-ID<slrnle33vs.v5n.hellsop@nibelheim.ninehells.com>
In reply to#12707
On Thu, 23 Jan 2014 18:05:10 +0000 (UTC), Denis McMahon wrote:
> And even now that I have written the whole damn sequence out, he'll still 
> fail to comprehend it and manage to make the same fuck up next week / 
> month / year / decade for as long as he continues trying to code his 
> website.

If you'd included one of the classic 

if ($a = '4') {
    echo "Why does this always happen to me?";
}

ones, I think you would have aced it.

-- 
"The last refuge of the insomniac is a sense of superiority to the
 sleeping world."
                --Leonard Cohen, The Favourite Game

[toc] | [prev] | [next] | [standalone]


#12709

FromArno Welzel <usenet@arnowelzel.de>
Date2014-01-25 10:20 +0100
Message-ID<52E381CC.9040406@arnowelzel.de>
In reply to#12707
Denis McMahon, 2014-01-23 19:05:

[...]
> Arno, remember that one of the rules of dealing with richard is that he 
> never has a more fucked up understanding of something than when he thinks 
> he understands it.

I know. But I don't want his, sorry, bullshit stay uncommented -
otherwise people my find this via Google and think any of is findings
are true, since no one commented it.


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de

[toc] | [prev] | [next] | [standalone]


#12666

FromDoug Miller <doug_at_milmac_dot_com@example.com>
Date2014-01-14 21:20 +0000
Message-ID<XnsA2B5A63508F91dougmilmaccom@78.46.70.116>
In reply to#12657
richard <noreply@example.com> wrote in news:18dy94v4tv51n.1f3ltkhc8door$.dlg@
40tude.net:

> 
> $go=$_GET['a'];
> if(empty($go)){$go=0;}
> 
> if ($go>=60 and $go<=69) { include
> "http://mroldies.net/songs/19".$go.".html";}
> if ($go>="A" and $go<="Z") <<<<<< 
> { include"http://mroldies.net/songs/".$go.".html";}
> 
> if ($go==2){include "http://mroldies.net/radio/24hours.php";}
> if ($go==1){include"http://mroldies.net/test/index2.php";}
> if ($go==0){include "http://mroldies.net/home1.php";}
> 
> Using this code I now get a warning stating that the file can't be found.
> "Zero" returns true for the marked line.

No, it does not. 

"Zero" is *greater than* "Z", as you can easily determine by running this at the command 
line:
<?php
if ("Zero" > "Z") echo 'yes';
?>

Neither does string zero "0".

*Numeric* zero 0 does, however.

> I can see where that would be the case using or.
> But not AND!
> Since "Zero" is less than "A"

No, it is not. "Zero" is *greater than* "A".

> then the condition returns false.

The reason the condition returns false is that "Zero" is also greater than "Z".

> Why do I not get the same warning from the first match test?
> "zero" is less than 69 so that should return true.

RTFM. This is all explained at php.net in the descriptions of how PHP does comparisons 
between strings, and between strings and numerics.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web