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 #184669 is a reply to message #184658] Tue, 14 January 2014 21:20 Go to previous message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma:
Senior Member
richard <noreply(at)example(dot)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.
[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: Tue Nov 26 23:17:36 GMT 2024

Total time taken to generate the page: 0.03681 seconds