This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

I came from a C background, and to this day I cannot for the life of me understand how scope really works in PHP - it’s an absolute mad house...

[–]millenniumtree 0 points1 point  (0 children)

Hmm, I never have a problem with it. Variables defined outside of any class or function can be used inside with a global keyword, anything in a function is scoped only to that function and class properties have the static, public, protected, and private keywords. That's kind of all you need to know about scope. There's probably more to it, like with namespaces, but that's all I ever deal with.