If we are dealing with a large codebase where the global variable may be r
Are you a Unix-based OS?
I usually do something like grep -rn 'global $myvar' .
in the top-level directory. This does a recursive search of files in the current directory for the declaration.
Or, if you want to get fancy you can search for only PHP files:
grep -rn --include '*.php' 'global $myvar' .