Best method to recognize unused variables
<p>I have code where I use some variables. Example:</p>

<pre><code>$name = "someName";
$output = sprintf($doingText, $name); // $doingText is here undefined
</code></pre>

<p>I want to search the code for surely undefined variables (some sort of static code analysing).</p>

<p>These variables should be all some language text. No problem until there, but I don't want to make manually a list which variables exist: I want to get the variable names and then make some html form where I can see them and put into database in variablename-text pairs.</p>

<p>Question is: how to search them? (I haven't found any script which is able to do this in PHP by googling...)</p>

<p>(p.s.: I don't know what is the best method to search them as there may not be only assignments by =, but also with <code>foreach ($arr as $val)</code> etc.)</p>
