seany123 Posted May 2, 2009 Share Posted May 2, 2009 im trying to do some variables, i wqas just wondering if someone can verify this would work? <?php $exploss1 = ($player->level - $enemy->level * 100 + 100); if($exploss1 <= 1) { $exploss1 = rand(0, 10); } Link to comment https://forums.phpfreaks.com/topic/156567-solved-trying-to-set-up-some-variables/ Share on other sites More sharing options...
Mchl Posted May 2, 2009 Share Posted May 2, 2009 The syntax is correct. Link to comment https://forums.phpfreaks.com/topic/156567-solved-trying-to-set-up-some-variables/#findComment-824350 Share on other sites More sharing options...
seany123 Posted May 2, 2009 Author Share Posted May 2, 2009 okay thankyou, i was just wondering because i keep seeing stuff like ... $exploss1 = ($player->level - $enemy->level * 100 + 100) <= 0 ? ($exploss1 = rand(0, 10) or something like that.. Link to comment https://forums.phpfreaks.com/topic/156567-solved-trying-to-set-up-some-variables/#findComment-824352 Share on other sites More sharing options...
GingerRobot Posted May 2, 2009 Share Posted May 2, 2009 That's a ternary operator. It's a kind-of short-hand for if statements. Link to comment https://forums.phpfreaks.com/topic/156567-solved-trying-to-set-up-some-variables/#findComment-824354 Share on other sites More sharing options...
seany123 Posted May 2, 2009 Author Share Posted May 2, 2009 okay well ill stick to what i know, cheers for the help Link to comment https://forums.phpfreaks.com/topic/156567-solved-trying-to-set-up-some-variables/#findComment-824356 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.