Variable watch in PHP

倖福魔咒の 提交于 2019-12-23 15:19:07

问题


Does PHP have the ability to watch a variable (or object property) and run a function when its value changes, similar to Gecko's Javascript watch function?


回答1:


XDebug might have this, but I don't know for sure.

If you're trying to debug a member variable on an object, you can use overloading:

public function __set($var, $val)
{
    if ($var == 'interesting') {
        echo "$var set to: ";
        var_dump($val);
    }
    $this->$var = $val;
}



回答2:


This would be possible when using XDebug along side an IDE like eclipse.



来源:https://stackoverflow.com/questions/385420/variable-watch-in-php

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