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 #184665 is a reply to message #184660] Tue, 14 January 2014 18:25 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
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
[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 07:11:09 GMT 2024

Total time taken to generate the page: 0.33609 seconds