3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Box { private $x; private $y; private $z; public function __construct($x, $y, $z) { $this->x = $x; $this->y = $y; $this->z = $z; } public function getX() { return $this->x; } public function getY() { return $this->y; } public function getZ() { return $this->z; } public function __toString() { return "[{$this->x}, {$this->y}, {$this->z}]"; } public function maxRozmer() { return max([$this->x, $this->y, $this->z]); } } //find max rozmer function cmp(Box $a, Box $b) : int { if($a->maxRozmer() == $b->maxRozmer()) { return 0; } return ($a->maxRozmer() > $b->maxRozmer()) ? -1 : 1; } $boxes = [ new Box(7,7,4), new Box(101,1,2), new Box(5,20,1), ]; $result = usort($boxes, "cmp"); print_r($result); print_r($boxes);
Output for git.master, git.master_jit, rfc.property-hooks
1Array ( [0] => Box Object ( [x:Box:private] => 101 [y:Box:private] => 1 [z:Box:private] => 2 ) [1] => Box Object ( [x:Box:private] => 5 [y:Box:private] => 20 [z:Box:private] => 1 ) [2] => Box Object ( [x:Box:private] => 7 [y:Box:private] => 7 [z:Box:private] => 4 ) )

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:
68.35 ms | 402 KiB | 8 Q