3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $mypi = 3.1415926535897932384626433832795028841971; $mypi = 3.141592653589793; $pi = pi(); printf("pi: %.24f, %.24f, %.24f\n", $pi, $mypi, M_PI); $l = strlen($mypi); echo "l: $l\n"; $d = pack("d", $mypi); $l = strlen($d); echo "l: $l\n"; $un = unpack("d", $d); $d = end($un); printf("%.24g\n", $d); $pi = 3.1415926535897932384626433832795028841971; $s = preg_split("//", $pi); $c = count($s); print_r($s); echo "c: $c\n"; echo gmp_strval($pi) . "\n";
based on Edf0u
Output for 5.4.0 - 5.5.34, 5.6.8 - 5.6.20, 5.6.28, 7.0.0 - 7.0.5, 7.0.14 - 7.1.0
pi: 3.141592653589793115997963, 3.141592653589793115997963, 3.141592653589793115997963 l: 15 l: 8 3.14159265358979311599796 Array ( [0] => [1] => 3 [2] => . [3] => 1 [4] => 4 [5] => 1 [6] => 5 [7] => 9 [8] => 2 [9] => 6 [10] => 5 [11] => 3 [12] => 5 [13] => 8 [14] => 9 [15] => 8 [16] => ) c: 17 Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in /in/9iihr on line 24
Output for 7.0.6
pi: 3.141592653589793115997963, 3.141592653589793115997963, 3.141592653589793115997963 l: 15 l: 8 3.14159265358979311599796 Array ( [0] => [1] => 3 [2] => . [3] => 1 [4] => 4 [5] => 1 [6] => 5 [7] => 9 [8] => 2 [9] => 6 [10] => 5 [11] => 3 [12] => 5 [13] => 8 [14] => 9 [15] => 8 [16] => ) c: 17 Fatal error: Uncaught Error: Call to undefined function gmp_strval() in /in/9iihr:24 Stack trace: #0 {main} thrown in /in/9iihr on line 24
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
pi: 3.141592653589800221425321, 3.141592653589793115997963, 3.141592653589800221425321 l: 15 l: 8 3.14159265358979311599796 Array ( [0] => [1] => 3 [2] => . [3] => 1 [4] => 4 [5] => 1 [6] => 5 [7] => 9 [8] => 2 [9] => 6 [10] => 5 [11] => 3 [12] => 5 [13] => 8 [14] => 9 [15] => 8 [16] => ) c: 17 3
Output for 5.2.1 - 5.3.29, 5.5.35, 5.6.21
pi: 3.141592653589793115997963, 3.141592653589793115997963, 3.141592653589793115997963 l: 15 l: 8 3.14159265358979311599796 Array ( [0] => [1] => 3 [2] => . [3] => 1 [4] => 4 [5] => 1 [6] => 5 [7] => 9 [8] => 2 [9] => 6 [10] => 5 [11] => 3 [12] => 5 [13] => 8 [14] => 9 [15] => 8 [16] => ) c: 17 Fatal error: Call to undefined function gmp_strval() in /in/9iihr on line 24
Process exited with code 255.
Output for 5.0.0 - 5.2.0
pi: 3.141592653589793115997963, 3.141592653589793115997963, 3.141592653589793115997963 l: 15 l: 8 Array ( [0] => [1] => 3 [2] => . [3] => 1 [4] => 4 [5] => 1 [6] => 5 [7] => 9 [8] => 2 [9] => 6 [10] => 5 [11] => 3 [12] => 5 [13] => 8 [14] => 9 [15] => 8 [16] => ) c: 17 Fatal error: Call to undefined function gmp_strval() in /in/9iihr on line 24
Process exited with code 255.
Output for 4.4.5 - 4.4.9
pi: 3.141592653589793115997963, 3.141592653589793115997963, 3.141592653589793115997963 l: 15 l: 8 Array ( [0] => [1] => 3 [2] => . [3] => 1 [4] => 4 [5] => 1 [6] => 5 [7] => 9 [8] => 2 [9] => 6 [10] => 5 [11] => 3 [12] => 5 [13] => 8 [14] => 9 [15] => 8 [16] => ) c: 17 Fatal error: Call to undefined function: gmp_strval() in /in/9iihr on line 24
Process exited with code 255.
Output for 4.3.2 - 4.4.4
pi: 3.141592653589793115997963, 3.141592653589793115997963, 3.141592653589793115997963 l: 15 l: 8 Array ( [0] => [1] => 3 [2] => . [3] => 1 [4] => 4 [5] => 1 [6] => 5 [7] => 9 [8] => 2 [9] => 6 [10] => 5 [11] => 3 [12] => 5 [13] => 8 [14] => 9 [15] => 8 [16] => ) c: 17 Fatal error: Call to undefined function: gmp_strval() in /in/9iihr on line 24
Process exited with code 255.
Output for 4.3.0 - 4.3.1
pi: 3.141592653589793115997963, 3.141592653589793115997963, 3.141592653589793115997963 l: 15 l: 8 Array ( [0] => [1] => 3 [2] => . [3] => 1 [4] => 4 [5] => 1 [6] => 5 [7] => 9 [8] => 2 [9] => 6 [10] => 5 [11] => 3 [12] => 5 [13] => 8 [14] => 9 [15] => 8 [16] => ) c: 17 Fatal error: Call to undefined function: gmp_strval() in /in/9iihr on line 24