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 AbstractNode implements NodeInterface { protected $uid; protected $nodes; protected $key; public function __construct($key = null) { $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 = null) { $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 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; } } $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 5.4.0 - 5.4.19
Parse error: syntax error, unexpected 'AbstractNode' (T_STRING), expecting class (T_CLASS) in /in/aaQg4 on line 22
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_STRING, expecting T_CLASS in /in/aaQg4 on line 22
Process exited with code 255.

preferences:
193.12 ms | 1395 KiB | 55 Q