tags:

views:

435

answers:

2

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

+1  A: 

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;
}
ieure
According to PHP docs (http://us3.php.net/manual/en/language.oop5.overloading.php) : "__set() is run when writing data to inaccessible members." It doesn't filter all member accesses.
strager
A: 

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

Shoan