Stop Microsoft

Miscellaneous => Programming & Networking => Topic started by: anphanax on 28 May 2005, 05:03

Title: PHP Scope Oddness, Getting Around?
Post by: anphanax on 28 May 2005, 05:03
I learned a few days ago, that in order to use variables in PHP that were declared in the global scope, you need to redeclare (well, use the global keyword with them) them in a function in order to use them, else the function will use it's own version (wth?).

Is there a way to tell the interpreter to scope things normally\properly?

I get the feeling this was done to make things "easier" somehow for people to write code in PHP. That wouldn't make sense. Even QuickBASIC programmers had to learn about scope.

EDIT: Sorry if this has already been brought up. Took a quick glance at the asked questions and didn't see it.