cloudll Posted August 16, 2011 Share Posted August 16, 2011 Hi guys, I was wondering if someone could help me with the if statement, I have tried tweaking it in various different ways with no luck. I'm looking for it to do something like this <?php if ($pos_x < 30) { echo "you hit a wall!"; if ($pos_x > 240) { echo "you hit a wall!"; if ($pos_y < 30) { echo "you hit a wall!"; if ($pos_y > 240) { echo "you hit a wall!"; ?> Any help would be greatly appreciated Link to comment https://forums.phpfreaks.com/topic/244881-if-statement-can-it-work-like-this/ Share on other sites More sharing options...
KevinM1 Posted August 16, 2011 Share Posted August 16, 2011 if ($pos_x < 30 || $pos_X > 240) { echo "You hit a wall"; } if ($pos_y < 30 || $pos_y > 240) { echo "You hit a wall"; } Link to comment https://forums.phpfreaks.com/topic/244881-if-statement-can-it-work-like-this/#findComment-1257938 Share on other sites More sharing options...
Psycho Posted August 16, 2011 Share Posted August 16, 2011 if ($pos_x < 30 || $pos_x > 240 || $pos_y < 30 || $pos_y > 240) { echo "You hit a wall."; } Link to comment https://forums.phpfreaks.com/topic/244881-if-statement-can-it-work-like-this/#findComment-1257939 Share on other sites More sharing options...
KevinM1 Posted August 16, 2011 Share Posted August 16, 2011 if ($pos_x < 30 || $pos_x > 240 || $pos_y < 30 || $pos_y > 240) { echo "You hit a wall."; } Gah! You're right. Man, I need to get to bed.... Link to comment https://forums.phpfreaks.com/topic/244881-if-statement-can-it-work-like-this/#findComment-1257940 Share on other sites More sharing options...
cloudll Posted August 16, 2011 Author Share Posted August 16, 2011 Thanks guys, worked a treat Link to comment https://forums.phpfreaks.com/topic/244881-if-statement-can-it-work-like-this/#findComment-1257945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.