开发者

Whats wrong with if (($x > 0 && 256 <= $x) || ($y > 0 && 256 <= $y))?

Whats wrong with

if (($x >开发者_如何学C; 0 && 256 <= $x) || ($y > 0 && 256 <= $y)) { 
//Do AWESOME action here 
} else { 
echo '<br><div align="center"><b>X and Y must be over 0 but equal or less than 256.</b></div>'; 
}

? That means if X is over 0 and X is 256 or less and y is over 0 and less then or equal to 256, to do somthing, right? I put in x 237 and y 144, it gives me a error saying "X and Y must be over 0 but equal or less than 256."


It should be

if (($x > 0 && $x <= 256) || ($y > 0 && $y <= 256)) {
    // Rest of your code
}

Before you where checking for it to be higher than 0 and higher or equal than 256, not lower or equal than 256.


   if (($x > 0 && 256 >= $x) || ($y > 0 && 256 >= $y))

But rather start with $x

   if (($x > 0 && $x <= 256) || ($y > 0 && $y <= 256))

Just like you would say in speech: x is less than or equal to 256.


I think you meant

if (($x > 0 &&  $x <= 256 ) || ($y > 0 && $y <= 256)){...}


here, try this:

(($x > 0 && 256 >= $x) || ($y > 0 && 256 >= $y))


Rewritten those are:

if ($x > 0 && $x >= 256) {
// ...
}

Which is probably not what you meant. Use this:

if ($x > 0 && $x <= 256) {
// ...
}


You want x and y both greater the 0 and less the equal to 256.

if($x > 0 && $x <= 256 && $y > 0 && $y<= 256) { 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜