Page 1 of 1

[SOLVED] php5.0.3: weird bug?

Posted: Sun Mar 06, 2005 8:15 pm
by timvw

Code: Select all

<?php
error_reporting(E_ALL);

$rows = array();
$rows&#1111;] = array('user' => 'timvw', 'credits' => 6);

$newcredits = $rows&#1111;0]&#1111;'credits']++;
echo "newcredits: $newcredits<br>";

$newcredits = $rows&#1111;0]&#1111;'credits'] + 1;
echo "newcredits: $newcredits<br>";

?>
outputs:

newcredits: 6
newcredits: 8

i don't think this behaviour is expected... but i'm always ready to learn something new :)

Posted: Sun Mar 06, 2005 8:25 pm
by feyd
that's correct.. $var++ is post-increment.. meaning, after execution (returning current state), the variable is incremented. ++$var is pre-increment, as you are expecting.

[SOLVED]

Posted: Sun Mar 06, 2005 9:37 pm
by timvw
time to go to bed for me... project completed and brain already stopped working :p