在 Netbeans PHP 调试器中查看静态变量内容 [英] View static variable content in Netbeans PHP debugger
问题描述
我在 Windows 桌面上使用 Netbeans 来调试在安装了 xdebug 的 Linux 服务器上远程运行的 PHP Web 应用程序.一个经常困扰我的缺失功能是:我无法查看类中静态变量的内容.很多时候我不得不求助于print"或var_dump"的方法来查找变量内容,非常不方便.
I use Netbeans on my windows desktop to debug a PHP web application remotely running on a Linux server with xdebug installed. One missing feature that constantly bothers me is: I can not view the content of static variables in a class. Often I have to resort to the "print" or "var_dump" method to find the variable content, which is very inconvenient.
有谁知道如何正确配置它?我在 Netbeans 菜单中找不到任何相关设置.我的 Netbeans 版本是在 Windows 7 上运行的 7.0.1,我的远程服务器是 CentOS 5.4,运行 PHP 5.2 和最新的 xdebug 模块.
Does anyone know how to config it properly? I failed to find any related settings in the Netbeans menu. My Netbeans version is 7.0.1 running on Windows 7, and my remote server is CentOS 5.4 running PHP 5.2 with the latest xdebug module.
推荐答案
好吧,看来 在 xdebug 2.1.3 中修复了(更像是添加"),但我还不能测试它,因为我的设置没有 DLL(仅限 VC9;希望也有 VC6).试一试.
Well, it seems fixed (more like "added") in xdebug 2.1.3, but I can't test it yet, as there aren't DLL's for my setup (VC9 only; hope there'll be VC6, too). Give it a go.
在那之前,使用手表(另一种很棒"的方法).使用链接中的示例(我在这里指的是 NetBeans):
Until then, use watches (another "great" method). Using the example in the link (and I'm reffering to NetBeans here):
class testclass {
static private $name;
static public function show_name() {
//do something with $name
self::$name = "Sir John\n" . self::$name;
return self::$name;
}
}
echo testclass::show_name();
- 在 return 语句处放置一个断点.
- 启动调试器
- 如果您没有看到Watches"选项卡,请转到
menu
->Windows
->Debugging
->手表
- 转到
Watches
选项卡,右键单击,New Watch
.输入self::$name
作为表达式.(对于常规变量,使用$varName
作为表达式).这是棘手的部分.直到现在我才知道这件事. - 运行代码.
- Put a breakpoint at the return statement.
- Start debugger
- If you don't see the "Watches" tab, go to
menu
->Windows
->Debugging
->Watches
- Go to
Watches
tab, right-click,New Watch
. Typeself::$name
as the expression. (for regular vars, use$varName
as expression). This was the tricky part. I didn't know about this until now. - Run code.
这篇关于在 Netbeans PHP 调试器中查看静态变量内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!