3v4l.org

run code in 300+ PHP versions simultaneously
<?php function facdef($n) { switch($n) { case 0: return 1; case 1: return 1; case 2: return 2; case 3: return 6; case 4: return 24; case 5: return 120; case 6: return 720; case 7: return 5040; case 8: return 40320; case 9: return 362880; case 10: return 3628800; case 11: return 39916800; case 12: return 479001600; case 13: return 6227020800; case 14: return 87178291200; case 15: return 1307674368000; case 16: return 20922789888000; case 17: return 355687428096000; case 18: return 6402373705728000; case 19: return 121645100408832000; case 20: return 2432902008176640000; case 21: return 51090942171709440000; case 22: return 1124000727777607680000; case 23: return 25852016738884976640000; } } function constify($a) { #regression constants return $a*0.424+0.548; } function scorefix($avg) { #if predicted score is small or negative, return something reasonable if ( $avg < 0.01 ) { return 10^(10^$avg-1) / 105.50984676065602; } else { return $avg; } } function sim($homeoff,$homedef,$awayoff,$awaydef,$mul,$natavg) { #returns homemu,awaymu for poisson to deal with return array(scorefix((($homeoff-$natavg)*max(constify($awaydef*$mul),0.25)/constify($natavg*$mul)+$awaydef)*$mul),scorefix((($homedef-$natavg)*max(constify($awayoff/$mul),0.25)/constify($natavg/$mul)+$awayoff)/$mul)); } function poisson($mu,$shift) { #returns array of poisson probabilities for scores $x = []; for ($i = 1 ; $i <= $shift ; $i++ ) { array_push($x,0.0); } $pcdf = 0.0; $a = exp(-1*$mu); echo count($a); while ( $pcdf < 0.999999 || count($x) < 5 ) { echo $mu^(count($x)-$shift)."\n"; echo facdef(count($x)-$shift)."\n"; array_push($x,$a*($mu^(count($x)-$shift))/facdef(count($x)-$shift)); echo count($x); $pcdf+=end($x); } return $x; } var_dump(poisson(1.1,0)); ?>
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, float given in /in/uhOuo:75 Stack trace: #0 /in/uhOuo(86): poisson(1.1, 0) #1 {main} thrown in /in/uhOuo on line 75
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, float given in /in/uhOuo:75 Stack trace: #0 /in/uhOuo(86): poisson(1.1, 0) #1 {main} thrown in /in/uhOuo on line 75
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, float given in /in/uhOuo:75 Stack trace: #0 /in/uhOuo(86): poisson(1.1, 0) #1 {main} thrown in /in/uhOuo on line 75
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Warning: count(): Parameter must be an array or an object that implements Countable in /in/uhOuo on line 75 1 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 11 1 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 01 2 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 32 3 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 26 4 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 524 5array(5) { [0]=> float(0.33287108369808) [1]=> float(0) [2]=> float(0.49930662554712) [3]=> float(0.11095702789936) [4]=> float(0.0693481424371) }
Output for 7.3.32 - 7.3.33
Warning: count(): Parameter must be an array or an object that implements Countable in /in/uhOuo on line 75 111 101 232 326 4524 5array(5) { [0]=> float(0.33287108369808) [1]=> float(0) [2]=> float(0.49930662554712) [3]=> float(0.11095702789936) [4]=> float(0.0693481424371) }
Output for 7.1.0 - 7.1.33
1 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 11 1 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 01 2 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 32 3 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 26 4 Notice: A non well formed numeric value encountered in /in/uhOuo on line 77 524 5array(5) { [0]=> float(0.33287108369808) [1]=> float(0) [2]=> float(0.49930662554712) [3]=> float(0.11095702789936) [4]=> float(0.0693481424371) }
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33
111 101 232 326 4524 5array(5) { [0]=> float(0.33287108369808) [1]=> float(0) [2]=> float(0.49930662554712) [3]=> float(0.11095702789936) [4]=> float(0.0693481424371) }

preferences:
214.48 ms | 402 KiB | 330 Q