3v4l.org

run code in 300+ PHP versions simultaneously
<?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'; protected 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());
Output for 5.4.18 - 5.4.19
Parse error: syntax error, unexpected 'return' (T_RETURN) in /in/IDshr on line 37
Process exited with code 255.
Output for 5.4.0 - 5.4.17
Parse error: syntax error, unexpected 'return' (T_RETURN) in /in/aR9l7 on line 37
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_RETURN in /in/aR9l7 on line 37
Process exited with code 255.

preferences:
184.24 ms | 1386 KiB | 55 Q