Fernando Bassani has posted an alternative to using globals in your scripts - creating "global objects" with the help of the Registry design pattern.
For a long time, the "programming good practices" tell us to avoid globals. In fact, this is a point of a large criticism in languages such as PHP. A nice solution to our global's "needs" is the Registry design pattern. With it, we can have a repository with the data that has to be accessible, removing them from the global scope.
Included in the post is all the code you'll need to get it to work. It uses a Singleton to grab the latest object and allows you to store values and define namespaces to keep data separate.