nickf
nickf

Reputation: 546035

Variable watch in PHP

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?

Upvotes: 4

Views: 4310

Answers (2)

Shoan
Shoan

Reputation: 4078

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

Upvotes: 0

ieure
ieure

Reputation: 2421

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;
}

Upvotes: 1

Related Questions