3v4l.org

run code in 300+ PHP versions simultaneously
<?php function add ($v1,$v2) { $v[] = (string) $v1; $v[] = (string) $v2; foreach ($v as $val) { preg_match('/\.(\d*)/',$match,$val); $dec[] = strlen($val); } var_dump($dec); } add(10.756,10.98324534); var_dump(bcadd(10.917,10)); var_dump(bcadd(10.917,10,0)); var_dump(bcadd(10.917,10,1)); var_dump(bcadd(10.917,10,2)); var_dump(bcadd(10.917,10,3)); var_dump(bcadd(10.917,10,4));
Output for 8.1.18 - 8.1.28, 8.2.5 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $match in /in/1Th4Q on line 6 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/1Th4Q on line 6 Fatal error: Uncaught TypeError: strlen(): Argument #1 ($string) must be of type string, array given in /in/1Th4Q:7 Stack trace: #0 /in/1Th4Q(11): add(10.756, 10.98324534) #1 {main} thrown in /in/1Th4Q on line 7
Process exited with code 255.
Output for 8.1.0 - 8.1.17, 8.2.0 - 8.2.4
Warning: Undefined variable $match in /in/1Th4Q on line 6 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/1Th4Q on line 6 Fatal error: Uncaught TypeError: strlen(): Argument #1 ($str) must be of type string, array given in /in/1Th4Q:7 Stack trace: #0 /in/1Th4Q(11): add(10.756, 10.98324534) #1 {main} thrown in /in/1Th4Q on line 7
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Warning: Undefined variable $match in /in/1Th4Q on line 6 Fatal error: Uncaught TypeError: strlen(): Argument #1 ($str) must be of type string, array given in /in/1Th4Q:7 Stack trace: #0 /in/1Th4Q(11): add(10.756, 10.98324534) #1 {main} thrown in /in/1Th4Q on line 7
Process exited with code 255.
Output for 7.4.33
Notice: Undefined variable: match in /in/1Th4Q on line 6 Warning: strlen() expects parameter 1 to be string, array given in /in/1Th4Q on line 7 Notice: Undefined variable: match in /in/1Th4Q on line 6 Warning: strlen() expects parameter 1 to be string, array given in /in/1Th4Q on line 7 array(2) { [0]=> NULL [1]=> NULL } Fatal error: Uncaught Error: Call to undefined function bcadd() in /in/1Th4Q:12 Stack trace: #0 {main} thrown in /in/1Th4Q on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
Notice: Undefined variable: match in /in/1Th4Q on line 6 Warning: strlen() expects parameter 1 to be string, array given in /in/1Th4Q on line 7 Notice: Undefined variable: match in /in/1Th4Q on line 6 Warning: strlen() expects parameter 1 to be string, array given in /in/1Th4Q on line 7 array(2) { [0]=> NULL [1]=> NULL } string(2) "20" string(2) "20" string(4) "20.9" string(5) "20.91" string(6) "20.917" string(7) "20.9170"
Output for 7.3.32 - 7.3.33
Warning: strlen() expects parameter 1 to be string, array given in /in/1Th4Q on line 7 Warning: strlen() expects parameter 1 to be string, array given in /in/1Th4Q on line 7 array(2) { [0]=> NULL [1]=> NULL } Fatal error: Uncaught Error: Call to undefined function bcadd() in /in/1Th4Q:12 Stack trace: #0 {main} thrown in /in/1Th4Q on line 12
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Notice: Undefined variable: match in /in/1Th4Q on line 6 Warning: strlen() expects parameter 1 to be string, array given in /in/1Th4Q on line 7 Notice: Undefined variable: match in /in/1Th4Q on line 6 Warning: strlen() expects parameter 1 to be string, array given in /in/1Th4Q on line 7 array(2) { [0]=> NULL [1]=> NULL } Fatal error: Call to undefined function bcadd() in /in/1Th4Q on line 12
Process exited with code 255.
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Notice: Undefined variable: match in /in/1Th4Q on line 6 Notice: Array to string conversion in /in/1Th4Q on line 7 Notice: Undefined variable: match in /in/1Th4Q on line 6 Notice: Array to string conversion in /in/1Th4Q on line 7 array(2) { [0]=> int(5) [1]=> int(5) } string(2) "20" string(2) "20" string(4) "20.9" string(5) "20.91" string(6) "20.917" string(7) "20.9170"
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.3
Notice: Undefined variable: match in /in/1Th4Q on line 6 Notice: Array to string conversion in /in/1Th4Q on line 7 Notice: Undefined variable: match in /in/1Th4Q on line 6 Notice: Array to string conversion in /in/1Th4Q on line 7 array(2) { [0]=> int(5) [1]=> int(5) } string(2) "20" string(2) "20" string(4) "20.9" string(5) "20.91" string(6) "20.917" string(7) "20.9170"

preferences:
260.59 ms | 403 KiB | 455 Q