title: Find declaration of a global variable in PHP
body: <h2>Is there a quick and concise way of finding the declaration of a global variable in PHP?</h2>
  
  <p>If we are dealing with a large codebase where the global variable may be referenced in many different files:</p>
  
  <ul>
  <li>Using <code>ctags</code> to jump to declaration takes you to the local statement where the global is brought into scope in the current file</li>
  <li>Searching for <code>global $foo</code> using <code>grep</code> or <code>ack</code> results in a list of files where the global was brought into scope, but not the exact declaration of the global variable</li>
  </ul>
  
  <p>Is there any tool/vim plugin/etc that will tell you exactly where the global is being declared for the first time?</p>
  
  <hr>
  
  <p><strong>Update:</strong> I guess you could set a watch breakpoint and look for the first access to the variable. Unfortunately, this type of breakpoint is not yet supported in Xdebug, so for my particular setup, it wouldn't work.</p>