问题
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