3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { function __construct() { $this->arr = array(1,34,3,98,9,76,45,4); } function joinNumbers($a, $b) { $t=10; while($b>=$t) $t*=10; return $a*$t+$b; } function arrangeNumbers() { $size=count($this->arr)/count($this->arr[0]); for($i=0;$i<$size-1;$i++) { for($j=$i+1;$j<$size;$j++) { if($this->joinNumbers($this->arr[$i],$this->arr[$j])<$this->joinNumbers($this->arr[$j],$this->arr[$i])) { $temp = $this->arr[$i]; $this->arr[$i] = $this->arr[$j]; $this->arr[$j] = $this->arr[$i]; } } } printf("Number is : "); for($i=0;$i<$size;$i++) { printf("%d",$this->arr[$i]); } printf("\n\n"); } } $test = new A; $test->arrangeNumbers();
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Creation of dynamic property A::$arr is deprecated in /in/lQ3Xl on line 4 Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given in /in/lQ3Xl:17 Stack trace: #0 /in/lQ3Xl(37): A->arrangeNumbers() #1 {main} thrown in /in/lQ3Xl on line 17
Process exited with code 255.
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given in /in/lQ3Xl:17 Stack trace: #0 /in/lQ3Xl(37): A->arrangeNumbers() #1 {main} thrown in /in/lQ3Xl on line 17
Process exited with code 255.
Output for 8.0.0 - 8.0.9
Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, int given in /in/lQ3Xl:17 Stack trace: #0 /in/lQ3Xl(37): A->arrangeNumbers() #1 {main} thrown in /in/lQ3Xl on line 17
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: count(): Parameter must be an array or an object that implements Countable in /in/lQ3Xl on line 17 Number is : 9999976454
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Number is : 9999976454

preferences:
214.41 ms | 402 KiB | 330 Q