3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class AHeap extends SplHeap { public function __construct($i) { foreach ($i as $obj) { $this->insert($obj); } } } class KeySort extends AHeap { protected function compare(object $val1, $val2) { if ($val1->key == $val2->key) { if ($val1->value == $val2->value) { return 0; } if ($val1->value > $val2->value){ return -1; } else { return 1; } } if ($val1->key > $val2->key){ return -1; } else { return 1; } } } $array = array( (object) array('key' => 0, 'value' => 'z'), (object) array('key' => 0, 'value' => 'a'), (object) array('key' => 2, 'value' => 'y'), (object) array('key' => 3, 'value' => 'b'), ); $heap = new KeySort($array); foreach ($heap as $val) { echo $val->key . ' - ' . $val->value . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Declaration of KeySort::compare(object $val1, $val2) must be compatible with SplHeap::compare(mixed $value1, mixed $value2): int in /in/B3Aju on line 15
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:
44.5 ms | 401 KiB | 8 Q