Jump to content

Are variables declared within a while loop accessible outside of the loop?


advancedfuture

Recommended Posts

yes, but unless you break out of the loop, php will not stop the loop until the condition is false. And you can't restart it after you break out of it.

 

edit to add:

 

hold up.  Are you calling a function inside the loop? You would need to declare a variable as global or else pass it as an argument to the function or else it is outside the function's scope. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.