ext_153627 ([identity profile] open-other-end.livejournal.com) wrote in [personal profile] funeralcrasher 2008-06-24 07:11 am (UTC)

$num = $num * 10 doesnt mean $num = 10. What's happening is you've set $num to 10, defined a function, ran a function that didn't actually affect $num, and then you've printed out $num again. Nothing's actually changed.

Is this Javascript? I don't know it too well, but I don't know how function declarations work. You need to say that $num is a parameter inside the function, and then return it back again. If you say instead something like

$num = 10
function multiply(var num)
{
$num = $num * 10;
return $num;
}
$num = multiply($num)
and then print out num, you should get 100.

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting