3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function isPerfect($n) { return $n[0]*$n[1]*$n[2]*$n[3]+1==pow(pow($n[0],2)+3*$n[0]+1,2); } var_dump(isPerfect([1,2,3,4])); var_dump(isPerfect(['1','2','3','4'])); var_dump(isPerfect([3,9,5,6])); var_dump(isPerfect([1,2,3,4,5])); var_dump(isPerfect([a,b,c,d])); var_dump(isPerfect([1,b,3,4])); var_dump(isPerfect([1001,1002,1003,1004]));
based on Ve222
Output for 7.2.0
bool(true) bool(true) bool(false) bool(true) Warning: Use of undefined constant a - assumed 'a' (this will throw an Error in a future version of PHP) in /in/jZZ5S on line 11 Warning: Use of undefined constant b - assumed 'b' (this will throw an Error in a future version of PHP) in /in/jZZ5S on line 11 Warning: Use of undefined constant c - assumed 'c' (this will throw an Error in a future version of PHP) in /in/jZZ5S on line 11 Warning: Use of undefined constant d - assumed 'd' (this will throw an Error in a future version of PHP) in /in/jZZ5S on line 11 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 bool(true) Warning: Use of undefined constant b - assumed 'b' (this will throw an Error in a future version of PHP) in /in/jZZ5S on line 12 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 bool(false) bool(true)
Output for 7.1.0 - 7.1.10
bool(true) bool(true) bool(false) bool(true) Notice: Use of undefined constant a - assumed 'a' in /in/jZZ5S on line 11 Notice: Use of undefined constant b - assumed 'b' in /in/jZZ5S on line 11 Notice: Use of undefined constant c - assumed 'c' in /in/jZZ5S on line 11 Notice: Use of undefined constant d - assumed 'd' in /in/jZZ5S on line 11 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 bool(true) Notice: Use of undefined constant b - assumed 'b' in /in/jZZ5S on line 12 Warning: A non-numeric value encountered in /in/jZZ5S on line 4 bool(false) bool(true)
Output for 5.4.2 - 7.0.20
bool(true) bool(true) bool(false) bool(true) Notice: Use of undefined constant a - assumed 'a' in /in/jZZ5S on line 11 Notice: Use of undefined constant b - assumed 'b' in /in/jZZ5S on line 11 Notice: Use of undefined constant c - assumed 'c' in /in/jZZ5S on line 11 Notice: Use of undefined constant d - assumed 'd' in /in/jZZ5S on line 11 bool(true) Notice: Use of undefined constant b - assumed 'b' in /in/jZZ5S on line 12 bool(false) bool(true)
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/jZZ5S on line 7
Process exited with code 255.