View static variable content in Netbeans PHP debugger

浪子不回头ぞ 提交于 2021-01-28 12:11:47

问题


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. Type self::$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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!