Page 1 of 1
test of boundaries fail - why? bug?
Posted: 16 Jul 2011 21:40
by CodeLobster
the 3rd line has proper values but it doesnt react?
it should pop an
echo if $test is minor than 0, larger than 1.
Code: Select all
$test = "-2";
if ($test >= 0 && $test <= 1) { echo "in the boundaries of 0 - 1 = $test"; }
elseif ($test < 0 && $test > 1) { echo "out of range! value: $test"; } // should echo!!!
elseif ($test > 1) { echo "OUT of range = > 1! value: $test"; } // this pops ok according to $test value
elseif ($test < 0) { echo "out of RANGE = < 0! value: $test"; } // this one too
Re: test of boundaries fail - why? bug?
Posted: 16 Jul 2011 21:54
by Stefan
CodeLobster wrote:the 3rd line has proper values but it doesnt react?
it should pop an
echo if $test is minor than 0, larger than 1.
Code: Select all
$test = "-2";
if ($test >= 0 && $test <= 1) { echo "A: in the boundaries of 0 - 1 = $test"; }
elseif ($test < 0 && $test > 1) { echo "B: out of range! value: $test"; } // should echo!!!
elseif ($test > 1) { echo "C: OUT of range = > 1! value: $test"; }
elseif ($test < 0) { echo "D: out of RANGE = < 0! value: $test"; }
* what should this means: "<0" AND ">1"
Nothing is less then zero AND more then "1" the same time.
* "$test < 0" is the right answer for "-2"
* "-2" is minor than 0, but not larger than 1.
Re: test of boundaries fail - why? bug?
Posted: 16 Jul 2011 22:03
by CodeLobster
im trying to test left (negative or lower) and right (positive or larger) in the same line but it seems to be not possible, right?
in other words
($test < 3 && $test > 6) = should return yes for 2, 1, 0... or 7, 8, 9...
Re: test of boundaries fail - why? bug?
Posted: 16 Jul 2011 22:25
by Stefan
CodeLobster wrote:
($test < 3 && $test > 6) = should return yes for 2, 1, 0... or 7, 8, 9...
Not sure if my mind is still working (saturday, 22:30)
but do you mean OR ?
($test < 3 || $test > 6)
IF var is less then 3 OR greater then 6, THEN echo yes, ELSE echo no
Code: Select all
$test = "-2";
if ($test < 3 || $test > 6){ msg "$". "test is $test";}else{msg "ELSE";}
Re: test of boundaries fail - why? bug?
Posted: 16 Jul 2011 23:14
by CodeLobster
oh no, my own newbieness' fault as im learning by examples and documentation.
by examples, in case.
i can understand my statement as both inclusive or exclusive so your first post made sense to me either.
i just needed something to work as your second post did. thanks man!