$_SESSION[$var] += $var;
You mean if $var==5, this should evaluate to $_SESSION[5] += 5; if not, what should it evaluate to?
I think you're wanting to pass the name of the variable (as a string) to the function, not the value.
function addTo($var)
{
if (!empty($$var))
{
@ $_SESSION[$var] += $$var;
}
}
.....
$Item1 = 5;
addTo('Item1');
But that won't work, because if you call addTo('Item1'), then the function becomes "if (!empty($Item1)){@ $_SESSION['Item1'] += $Item1;}", and $Item1 doesn't have a value.
function addTo($name, $value)
{
if (!empty($name))
{
@ $_SESSION[$name] += $value;
}
}
...
addTo('Item1', 5);