Q695 Posted October 15, 2012 Share Posted October 15, 2012 <?php //started with: $energy=$row_c['energy']--; //tried: $energy=$row_c['energy']; echo $energy; $energy=$energy--; //value doesn't go -1, what's wrong? ?> 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 Quote 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. 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; ?> 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 Link to comment https://forums.phpfreaks.com/topic/269472-value-in-value-out/#findComment-1385242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.