funeralcrasher: (Default)
$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?

Date: 2008-06-24 10:59 am (UTC)From: [identity profile] pkbarbiedoll.livejournal.com
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.

Profile

funeralcrasher: (Default)
funeralcrasher

June 2020

S M T W T F S
 123456
78910111213
141516 1718 1920
21222324252627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 29th, 2025 01:11 pm
Powered by Dreamwidth Studios