3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface NodeInterface { public function addNode(Node $node); public function hasNodes(); public function getKey(); public function setKey($key); public function getNodes(); public function nodes(); public function getUid(); public function uid(); public function key(); } interface LeafInterface extends NodeInterface { public function getValue(); public function vlaue(); } abstract class AbstractNode implements NodeInterface { protected $uid; protected $nodes; protected $key; public function __construct($key) { $this->uid = rand(0, 9) . md5(rand(10, 99) . time() . rand(100, 999)) . rand(1000, 9999); $this->key = $key; $this->nodes = []; } public function getKey() { return $this->value->key; } public function key() { return $this->value->key; } public function setKey($key) { $this->value->key = $key; return $this; } public function getUid() { return $this->uid; } public function uid() { return $this->uid; } } class ArrNode extends AbstractNode { public function addNode(Node $node) { $this->nodes[] = $node; return $this; } public function hasNodes() { return count($this->nodes) > 0; } public function getNodes() { return $this->nodes; } public function nodes() { return $this->nodes; } } class ArrLeaf extends AbstractNode implements LeafInterface { protected $value; public function __construct($key, $value) { parent::__construct($key); $this->value = $value; } public function addNode(Node $node) { return false; } public function hasNodes() { return false; } public function getNodes() { return false; } public function nodes() { return false; } public function getValue() { return $this->value; } public function value() { return $this->value; } } $pk = new ArrComp('pk'); $pkAttrs = new ArrComp('@attributes'); $pkAttrs->addNode(new ArraLeaf('excl', 'web_actions')); $pkAttrs->addNode(new ArraLeaf('system', 'depWEBsys')); $pkAttrs->addNode(new ArraLeaf('id', 'packet20130905133323986')); $comp->addNode($pkAttrs); var_dump($comp);
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.24, 7.3.0 - 7.3.12
Fatal error: Class ArrLeaf contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (LeafInterface::vlaue) in /in/NYq3Y on line 86
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Fatal error: Class ArrLeaf contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (LeafInterface::vlaue) in /in/NYq3Y on line 125
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/NYq3Y on line 32
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/NYq3Y on line 32
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/NYq3Y on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/NYq3Y on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/NYq3Y on line 3
Process exited with code 255.

preferences:
164.79 ms | 401 KiB | 262 Q