1

Do PHP5.3 have any known bug issue that makes non static variables in scope behave Static ? I donno why in a if{}Scope I've

{
  echo $_not_static;
  $_not_static = 5;
}

First Time it fires E_NOTICE as it should But second time it prints 5. I was Struggling with this for 3+ hours but not getting any hint of a fault from my side.

1 Answer 1

4

Variables are function-scoped, regardless on the block they are in, and that's in any PHP version. If you declare a variable inside an if block, and you enter there, it will stay declared after the if finishes, for the entire function scope.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.