arma
arma

Reputation: 4124

Is it possible to know where variable were set?

I was wondering if it is possible to see where variable were set in php code? That would make debugging really easier as i assign different values to same variable based on some condition.

Upvotes: 2

Views: 128

Answers (3)

djn
djn

Reputation: 3948

Sure. In Notepad++ you can install the SourceCookifier plugin.

From the website: "A plugin which uses Exuberant Ctags to parse either only the currently activated source file or multiple files of so-called sessions. The results are shown and can be browsed in a treeview inside of a dockable window."

From my own experience: it just works - for variables, functions, properties, methods, classes, interfaces... and some HTML and javascript stuff too.

Upvotes: 1

Pekka
Pekka

Reputation: 449823

Nope.

However, many good PHP IDEs (at least NuSphere's phpEd, I'm sure Zend must have that too?) offer a possibility to jump to the point at which the variable was first used, and highlight all its occurrences.

Upvotes: 3

Ólafur Waage
Ólafur Waage

Reputation: 70031

If you are wondering about debugging. Do this.

if(condition)
{
    echo "1";
    $var = "something";
}
elseif(othercondition)
{
    echo "2";
    $var = "something";
}
...

Etc, this is really quickly done and you can see the number quickly in the output or a log file.

Upvotes: 1

Related Questions