3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MenuLinkTreeElement { public $link; public $subtree; public $depth; public $hasChildren; public $inActiveTrail; public $access; public $options; public function __construct($link, $has_children, $depth, $in_active_trail, array $subtree) { $this->link = $link; $this->hasChildren = $has_children; $this->depth = $depth; $this->subtree = $subtree; $this->inActiveTrail = $in_active_trail; $this->access = NULL; $this->options = array(); } public function count() { $sum = function ($carry, MenuLinkTreeElement $element) { return $carry + $element->count(); }; return 1 + array_reduce($this->subtree, $sum); } } $input = array( ); $array_start = microtime(TRUE); $storage = array(); for ($i = 0; $i < 1000; $i++) { $storage[] = array( 'link' => new StdClass(); 'has_children' => TRUE, 'depth' => 3, 'in_active_trail' => FALSE, 'below' => array(), 'access' => NULL, 'options' => array(), ); } $array_time = microtime(TRUE) - $array_start; $object_start = microtime(TRUE); $storage = array(); for ($i = 0; $i < 1000; $i++) { $storage[] = new MenuLinkTreeElement(new StdClass(), TRUE, 3, FALSE, array()); } $object_time = microtime(TRUE) - $object_start; echo 'arrays: ' . number_format($array_time, 3) . ' s'; echo 'objects: ' . number_format($object_time, 3) . ' s';
Output for 5.3.0 - 5.4.30
Parse error: syntax error, unexpected ';', expecting ')' in /in/RkOmo on line 40
Process exited with code 255.