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


Groups > comp.lang.php > #12658

Re: include capturing wrong value

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.php
Subject Re: include capturing wrong value
Date 2014-01-14 17:23 +0000
Organization A noiseless patient Spider
Message-ID <lb3rqd$adc$1@dont-email.me> (permalink)
References <18dy94v4tv51n.1f3ltkhc8door$.dlg@40tude.net>

Show all headers | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web