When using increment on variables in Javascript, lint says that x += 1
is preferred over x ++
.
But what about in PHP?
Is there any difference between the +=
and ++
or does it just not really matter?
When using increment on variables in Javascript, lint says that x += 1
is preferred over x ++
.
But what about in PHP?
Is there any difference between the +=
and ++
or does it just not really matter?
Well whatever you might say about conventions, try running the following...
$i = 1; $s = 's';
$i++; $s++;
echo $i.'<br>'.$s.'<br>';
$i = 1; $s = 's';
$i += 1; $s += 1;
echo $i.'<br>'.$s.'<br>';
the output is somewhat unexpected...
2
t
2
1
so I would say it could matter very much which is chosen!