Quick snippet to reset all public instance variables inside a PHP class back to their original values.
public function reset() { foreach (get_class_vars(get_class($this)) as $name => $default) { $this->$name = $default; } }
Can’t take credit for the code though. Found it on a website somewhere and have used it in pretty much every class I build. Problem is I can’t remember where it was originally.
Be First to Comment