i'm confused about the php variable scope. such as:
while(true){
$var = "yes , it is a test!";
}
printf($var)
the $var
is defined in while statement scope , how could we get it outside it's scope ? and i can't find explanation on the document .
i wonder how php deal with it's scope .
while
is not a function. scope of variable refers to variable inside functions
and classes
In PHP, a while loop doesn't create a new scope. So it will be available in the function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With