3v4l.org

run code in 300+ PHP versions simultaneously
<?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]));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
bool(true) bool(true) bool(false) bool(true) Fatal error: Uncaught TypeError: Unsupported operand types: string * string in /in/LtBpD:4 Stack trace: #0 /in/LtBpD(11): isPerfect(Array) #1 {main} thrown in /in/LtBpD on line 4
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
bool(true) bool(true) bool(false) bool(true) Warning: A non-numeric value encountered in /in/LtBpD on line 4 Warning: A non-numeric value encountered in /in/LtBpD on line 4 Warning: A non-numeric value encountered in /in/LtBpD on line 4 Warning: A non-numeric value encountered in /in/LtBpD on line 4 Warning: A non-numeric value encountered in /in/LtBpD on line 4 Warning: A non-numeric value encountered in /in/LtBpD on line 4 bool(true) Warning: A non-numeric value encountered in /in/LtBpD on line 4 bool(false) bool(true)
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33
bool(true) bool(true) bool(false) bool(true) bool(true) bool(false) bool(true)

preferences:
267.78 ms | 402 KiB | 339 Q