funeralcrasher: (Default)
funeralcrasher ([personal profile] funeralcrasher) wrote2008-06-23 10:33 am

Stumped.

$num = 10;
function multiply()
{
$num = $num * 10;
}
multiply();
echo $num;


This prints "10" to the screen.

$num = $num * 10;
echo $num;


But this prints "0".

Why is that?

[identity profile] pkbarbiedoll.livejournal.com 2008-06-24 10:59 am (UTC)(link)
Duh! I just saw that.. Because there isn't a global declaration in the function, the variable doesn't exist to the "outside world". I feel teh stoopid this am. lol.
thanks for the drawn out expl.