3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Node { protected $_type; protected $_props; protected $_children; public function __construct($type, array $props = null) { $this->_type = $type; $this->_props = array(); $this->_children = array(); if (null !== $props) { $this->setProps($props); } } public function getType() { return $this->_type; } public function addChild(Euhit_Markup_Latex_Parser_Node $node) { $this->_children[] = $node; return $this; } public function getChildren() { return $this->_children; } public function setProps(array $props) { foreach ($props as $key => $value) { $this->setProp($key, $value); } return $this; } public function setProp($key, $value) { $this->_props[$key] = $value; return $this; } public function &getProp($key) { if (!isset($this->_props[$key])) { $this->_props[$key] = null; } return $this->_props[$key]; } public function __set($key, $value) { $this->setProp($key, $value); } public function &__get($key) { return $this->getProp($key); } } $node = new Node(1024); $dupa = &$node->dupa; $dupa .= 'DUUPA!!!'; echo $node->dupa;
Output for 5.1.0 - 5.1.6, 5.2.1 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
DUUPA!!!
Output for 5.2.0
Notice: Indirect modification of overloaded property Node::$dupa has no effect in /in/SVAZ8 on line 72
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/SVAZ8 on line 10
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SVAZ8 on line 6
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, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SVAZ8 on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/SVAZ8 on line 6
Process exited with code 255.

preferences:
263.89 ms | 401 KiB | 398 Q