- print_r: documentation ( source)
<?php
class ObjectOne {
protected $someParam = 'foo';
protected $someOtherParam = 'bar';
protected $saveMe = NULL;
protected function update() {
$this->someParam = 'FOO';
$this->someOtherParam = 'BAR';
return true;
}
protected function revert(){
$this->someParam = $this->saveMe->someParam;
$this->someOtherParam = $this->saveMe->someOtherParam;
$this->saveMe = NULL;
}
}
class ObjectTwo extends ObjectOne {
protected $someParam = 'faa';
protected $someOtherParam = 'bor';
public function update() {
$this->saveMe = $this;
if(parent::update()) {
$this->someParam = 'poo';
if($this->someParam === 'foo') {
return true;
} else {
$this->revert();
parent::update();
return false;
}
} else {
return false;
}
}
}
$testOb = new ObjectTwo();
print_r($testOb->update());