3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Move { var $direction; var $value; var $x; var $y; public static function initializeEmpty(){ return (new Move(array(0, 0), "NONE", -1)); } 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 : $this; } public static function maxValDirection($moves, $board, $player, $pos){ $best = Move::initializeEmpty(); foreach($moves as $m){ $m->setValue($board, $player, $pos); $best = $m->compare($best); } return $best; } public function setValue($board, $player, $pos){ echo "0"; if ($board[$y][$x] != "-") $this->value = -1; else $this->value = 1; } } define("MAXSIZE", 100); echo MAXSIZE; define("ABCD", 100); echo ABCD; define(P1, "r"); define(P2, "l"); define(WALL, "#"); function nextMove($player,$pos,$board){ $moves = array(); array_push($moves, new Move(array($pos[0] - 1, $pos[1]), "UP", -1)); array_push($moves, new Move(array($pos[0] + 1, $pos[1]), "DOWN", -1)); array_push($moves, new Move(array($pos[0], $pos[1] - 1), "LEFT", -1)); array_push($moves, new Move(array($pos[0], $pos[1] + 1), "RIGHT", -1)); return Move::maxValDirection($moves, $board, $player, $pos)->direction; } $m1 = Move::initializeEmpty(); $m2 = new Move(array(0, 1), "RIGHT", 10); print_r(Move::maxValDirection(array($m1, $m2), "", "", "")); ?>
Output for git.master, git.master_jit, rfc.property-hooks
100100 Fatal error: Uncaught Error: Undefined constant "P1" in /in/kckUc:46 Stack trace: #0 {main} thrown in /in/kckUc on line 46
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
46.21 ms | 401 KiB | 8 Q