Q695 Posted October 15, 2012 Share Posted October 15, 2012 (edited) <?php //started with: $energy=$row_c['energy']--; //tried: $energy=$row_c['energy']; echo $energy; $energy=$energy--; //value doesn't go -1, what's wrong? ?> Edited October 15, 2012 by Q695 Quote Link to comment https://forums.phpfreaks.com/topic/269472-value-in-value-out/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2012 Share Posted October 15, 2012 Increment/decrement Operators ++$a Pre-increment Increments $a by one, then returns $a. $a++ Post-increment Returns $a, then increments $a by one. --$a Pre-decrement Decrements $a by one, then returns $a. $a-- Post-decrement Returns $a, then decrements $a by one. Quote Link to comment https://forums.phpfreaks.com/topic/269472-value-in-value-out/#findComment-1385238 Share on other sites More sharing options...
DarkerAngel Posted October 15, 2012 Share Posted October 15, 2012 Assuming $energy is an integer You would only need: $energy--; As oppose to: $energy=$energy--; So try as a full code: <?php $energy=$row_c['energy']; $energy--; echo $energy; ?> Quote Link to comment https://forums.phpfreaks.com/topic/269472-value-in-value-out/#findComment-1385239 Share on other sites More sharing options...
Q695 Posted October 15, 2012 Author Share Posted October 15, 2012 Thanks, Darker Angel. I didn't know what was going wrong, but whatever you did solved it Quote Link to comment https://forums.phpfreaks.com/topic/269472-value-in-value-out/#findComment-1385242 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.