3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Move { var $direction; var $value; var $x; var $y; public static function initializeEmpty(){ return (new Move(array(0, 0), "NONE", -2)); } public function __construct($pos, $direction, $value){ $this->y = $pos[0]; $this->x = $pos[1]; $this->value = $value; $this->direction = $direction; } public function compare($move){ return $move->value > $this->value ? $move->value : $this->value; } public static function maxValDirection($moves){ $best = Move::initializeEmpty(); foreach($moves as $m){ $best = $move->compare($best); } return $best; } } $m1 = Move::initializeEmpty(); $m2 = new Move(array(0, 1), "RIGHT", 10); print_r(Move::maxValDirection(array($m1, $m2))); ?>
based on ibpLZ
Output for 7.0.5 - 7.2.0
Notice: Undefined variable: move in /in/K7csP on line 26 Fatal error: Uncaught Error: Call to a member function compare() on null in /in/K7csP:26 Stack trace: #0 /in/K7csP(33): Move::maxValDirection(Array) #1 {main} thrown in /in/K7csP on line 26
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: move in /in/K7csP on line 26 Fatal error: Uncaught Error: Call to a member function compare() on unknown in /in/K7csP:26 Stack trace: #0 /in/K7csP(33): Move::maxValDirection(Array) #1 {main} thrown in /in/K7csP on line 26
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Notice: Undefined variable: move in /in/K7csP on line 26 Fatal error: Call to a member function compare() on null in /in/K7csP on line 26
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Notice: Undefined variable: move in /in/K7csP on line 26 Fatal error: Call to a member function compare() on a non-object in /in/K7csP on line 26
Process exited with code 255.