advancedfuture Posted June 24, 2008 Share Posted June 24, 2008 Are variables declared within a while loop accessible outside of the loop? Quote Link to comment https://forums.phpfreaks.com/topic/111742-are-variables-declared-within-a-while-loop-accessible-outside-of-the-loop/ Share on other sites More sharing options...
.josh Posted June 24, 2008 Share Posted June 24, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/111742-are-variables-declared-within-a-while-loop-accessible-outside-of-the-loop/#findComment-573618 Share on other sites More sharing options...
kenrbnsn Posted June 24, 2008 Share Posted June 24, 2008 Yes. Short question get short answers. Do you have a problem? Ken Quote Link to comment https://forums.phpfreaks.com/topic/111742-are-variables-declared-within-a-while-loop-accessible-outside-of-the-loop/#findComment-573619 Share on other sites More sharing options...
advancedfuture Posted June 24, 2008 Author Share Posted June 24, 2008 nope just curious, I was having a problem, and thought it may be it. Thank you for answering my short question, now I can more adequately diagnose the problem. Quote Link to comment https://forums.phpfreaks.com/topic/111742-are-variables-declared-within-a-while-loop-accessible-outside-of-the-loop/#findComment-573672 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.