I'm using Netbeans IDE, it shows a warning next to undeclared variables - very useful.
If I have this at the top of a file
global $CFG;
then the warnings go away because the variable has been declared.
But is this good practice? Are they any advantages? The code still works without the declaration.
Note: This is for files that have code outside of functions.