|
|
|
|
Re: include capturing wrong value [message #184664 is a reply to message #184660] |
Tue, 14 January 2014 18:10   |
Daniel Pitts
Messages: 68 Registered: May 2012
Karma: 0
|
Member |
|
|
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";}
|
|
|
Re: include capturing wrong value [message #184665 is a reply to message #184660] |
Tue, 14 January 2014 18:25   |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
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(at)gmail(dot)com
|
|
|
|
|
Re: include capturing wrong value [message #184731 is a reply to message #184730] |
Thu, 23 January 2014 18:05   |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
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(at)gmail(dot)com
|
|
|
|
Re: include capturing wrong value [message #184733 is a reply to message #184731] |
Sat, 25 January 2014 09:20  |
Arno Welzel
Messages: 317 Registered: October 2011
Karma: 0
|
Senior Member |
|
|
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
|
|
|