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

Home » Imported messages » comp.lang.php » include capturing wrong value
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: include capturing wrong value [message #184731 is a reply to message #184730] Thu, 23 January 2014 18:05 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: <script>alert(1)</script>
Next Topic: I Need to search over 100 largeish text documents efficiently. What's the best approach?
Goto Forum:
  

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

Current Time: Sat Nov 23 16:49:37 GMT 2024

Total time taken to generate the page: 0.09665 seconds