3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Protocol { public function setProtocolId($id) {return $this;} public function setCreationDate($id) {return $this;} public function setFleet($fleet) { return $this;} } class Fleet {} $data = array('status_date' => 'abc'); map($data); function map(Array $data) { if (isset(@$data['protocol_id'])) { $data = array($data); } $protocols = array(); try { foreach ($data as $_data) { $protocol = new Protocol(); $protocol->setProtocolId($_data['protocol_id']) ->setCreationDate(new DateTime($_data['creation_date'], new DateTimeZone('UTC'))); if (!empty($_data['fleet_id'])) { $protocol->setFleet(new Fleet($_data['fleet_id'])); } $protocols[] = $protocol; } } catch (Exception $e) { echo $e; throw new Exception('Error when trying to map result into Protocol object'); } }
Output for hhvm-3.10.0 - 3.12.0
Output for 5.3.0 - 5.4.29
Parse error: syntax error, unexpected '@' in /in/NrvkP on line 16
Process exited with code 255.