seany123 Posted March 2, 2009 Share Posted March 2, 2009 i am making a game and in this battle page i have to write how much exp the winner of a fight gains... which is this... $exploss1 = ($player->level - $enemy->level); but can anyone show me how to make it so the maximun is 10,000?? im not quite sure how to do it.. something like... $exploss1 = ($player->level - $enemy->level < 10000); Quote Link to comment https://forums.phpfreaks.com/topic/147639-just-quick-help/ Share on other sites More sharing options...
rhodesa Posted March 2, 2009 Share Posted March 2, 2009 $exploss1 = ($player->level - $enemy->level); if($exploss1 > 10000) $exploss1 = 10000; Quote Link to comment https://forums.phpfreaks.com/topic/147639-just-quick-help/#findComment-775048 Share on other sites More sharing options...
seany123 Posted March 2, 2009 Author Share Posted March 2, 2009 okay cheers edit: does the if not need {}s ?? Quote Link to comment https://forums.phpfreaks.com/topic/147639-just-quick-help/#findComment-775054 Share on other sites More sharing options...
corbin Posted March 2, 2009 Share Posted March 2, 2009 The syntax of if is: if(condition) statement {} essentially groups multiple statements into 1 such that the code inside the {} block is viewed as one statement (logically, not executionally). So, no they are not needed if only 1 statement is to be executed. Quote Link to comment https://forums.phpfreaks.com/topic/147639-just-quick-help/#findComment-775060 Share on other sites More sharing options...
Daniel0 Posted March 2, 2009 Share Posted March 2, 2009 Though I prefer to leave them for consistency and readability. Quote Link to comment https://forums.phpfreaks.com/topic/147639-just-quick-help/#findComment-775068 Share on other sites More sharing options...
corbin Posted March 2, 2009 Share Posted March 2, 2009 Yeah, I usually use them whether I have statement line or 9128390123. Just looks better to me ;p. Although sometimes I cram stuff on one line. if(blah) bleh; Quote Link to comment https://forums.phpfreaks.com/topic/147639-just-quick-help/#findComment-775079 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.