- Disallow variable overwrite in PHP
- class Test
- {
- private $variable;
- private $frozen = false;
- public function freeze() {
- $this->frozen = true;
- }
- public function setVariable($value) {
- if ($this->frozen)
- throw new Exception("...");
- $this->variable = $value;
- }
- }