开发者

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.


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜