问题
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.
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.
回答1:
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.
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();
- 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.
回答2:
If you control-click the variable, does it not take you to the variable definition automatically? This is the behavior I have.
来源:https://stackoverflow.com/questions/7935684/view-static-variable-content-in-netbeans-php-debugger