default value of variables
Posted: Sat May 03, 2003 4:11 am
hello,
look at this (example-)code:
this repeatly adds the value of $i to variable $a.
my question is:
If $a was never used before in this script, can I be sure that it always has "0" as its default integer value and $a is ALWAYS 10 after running this loop or could it be possible that it has another value. I couldn't find any informaton about this. I know in C a Varible should be initialized (with 0 f.ex.). I made some tests and the vars never had another value than zero - was this fortunity or can I be really sure that it neve rhappens?
look at this (example-)code:
Code: Select all
for ($i=0; $i<5;$i++)
{
$a += $i;
}my question is:
If $a was never used before in this script, can I be sure that it always has "0" as its default integer value and $a is ALWAYS 10 after running this loop or could it be possible that it has another value. I couldn't find any informaton about this. I know in C a Varible should be initialized (with 0 f.ex.). I made some tests and the vars never had another value than zero - was this fortunity or can I be really sure that it neve rhappens?