3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function isPerfect($n) { return count($a)==4&$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 LtBpD
Output for 7.2.0
Notice: Undefined variable: a in /in/4LLYN on line 4 Warning: count(): Parameter must be an array or an object that implements Countable in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 Warning: count(): Parameter must be an array or an object that implements Countable in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 Warning: count(): Parameter must be an array or an object that implements Countable in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 Warning: count(): Parameter must be an array or an object that implements Countable in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 Warning: count(): Parameter must be an array or an object that implements Countable in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 Warning: count(): Parameter must be an array or an object that implements Countable in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 Warning: count(): Parameter must be an array or an object that implements Countable in /in/4LLYN on line 4 int(0)
Output for 7.1.0 - 7.1.10
Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 Warning: A non-numeric value encountered in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0)
Output for 5.4.2 - 7.0.20
Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0) Notice: Undefined variable: a in /in/4LLYN on line 4 int(0)
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/4LLYN on line 7
Process exited with code 255.