php variable scope -


i'm confused php variable scope. such as:

while(true){     $var = "yes , test!";   }   printf($var) 

the $var defined in while statement scope , how outside it's scope ? , can't find explanation on document .

i wonder how php deal it's scope .

if while(true) not out of while, wouldn't matter. if have real expression, (this useless example, know)

$i=0 while($i<10){     $var = "yes , test!";     $i++;  }   printf($var); 

will work. there no special "while" variable scope, printf print string. check : http://php.net/manual/en/language.variables.scope.php


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -