3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $number = 1234.56; // let's print the international format for the en_US locale setlocale(LC_MONETARY, 'en_US'); echo money_format('%i', $number) . "\n"; // USD 1,234.56 // Italian national format with 2 decimals` setlocale(LC_MONETARY, 'it_IT'); echo money_format('%.2n', $number) . "\n"; // Eu 1.234,56 // Using a negative number $number = -1234.5672; // US national format, using () for negative numbers // and 10 digits for left precision setlocale(LC_MONETARY, 'en_US'); echo money_format('%(#10n', $number) . "\n"; // ($ 1,234.57) // Similar format as above, adding the use of 2 digits of right // precision and '*' as a fill character echo money_format('%=*(#10.2n', $number) . "\n"; // ($********1,234.57) // Let's justify to the left, with 14 positions of width, 8 digits of // left precision, 2 of right precision, withouth grouping character // and using the international format for the de_DE locale. setlocale(LC_MONETARY, 'de_DE'); echo money_format('%=*^-14#8.2i', 1234.56) . "\n"; // Eu 1234,56**** // Let's add some blurb before and after the conversion specification setlocale(LC_MONETARY, 'en_GB'); $fmt = 'The final value is %i (after a 10%% discount)'; echo money_format($fmt, 1234.56) . "\n"; // The final value is GBP 1,234.56 (after a 10% discount)
based on RDIkM

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.3.10.0130.00316.29
7.3.00.0030.01016.53
7.2.130.0030.01216.63
7.2.120.0090.00616.64
7.2.110.0060.00916.63
7.2.100.0120.00316.55
7.2.90.0040.00816.80
7.2.80.0060.00916.82
7.2.70.0070.01316.86
7.2.60.0170.00716.56
7.2.50.0130.00316.62
7.2.40.0030.00916.79
7.2.30.0090.00016.92
7.2.20.0070.00716.61
7.2.10.0120.00317.03
7.2.00.0100.00518.18
7.1.250.0000.00915.63
7.1.200.0060.00915.81
7.1.100.0080.01117.95
7.1.70.0030.00317.17
7.1.60.0090.01319.46
7.1.50.0070.01516.92
7.1.00.0000.08022.48
7.0.200.0040.00416.55
7.0.140.0000.03721.97
7.0.60.0300.06719.98
7.0.50.0000.04317.84
7.0.40.0000.05019.97
7.0.30.0230.03720.13
7.0.20.0330.07720.19
7.0.10.0030.05720.06
7.0.00.0000.04320.20
5.6.280.0000.07721.13
5.6.210.0100.08020.72
5.6.200.0100.05018.22
5.6.190.0100.04020.58
5.6.180.0370.07020.49
5.6.170.0300.08020.44
5.6.160.0130.07320.51
5.6.150.0100.07318.16
5.6.140.0070.04018.17
5.6.130.0070.07318.18
5.6.120.0070.07321.00
5.6.110.0070.08720.96
5.6.100.0000.07021.04
5.6.90.0100.04720.88
5.6.80.0130.07320.50
5.5.350.0000.04320.48
5.5.340.0070.08317.92
5.5.330.0070.05020.25
5.5.320.0330.04020.23
5.5.310.0330.07320.41
5.5.300.0070.08018.02
5.5.290.0030.04017.98
5.5.280.0070.04720.76
5.5.270.0070.05720.68
5.5.260.0100.08720.86
5.5.250.0100.04320.68
5.5.240.0030.04020.26
5.4.450.0430.08319.42
5.4.440.0300.06019.55
5.4.430.0070.05719.53
5.4.420.0070.06019.54
5.4.410.0100.05319.39
5.4.400.0100.05319.23
5.4.390.0300.06018.69
5.4.380.0170.05718.80
5.4.370.0130.05718.71
5.4.360.0130.05718.56
5.4.350.0200.06018.84
5.4.340.0230.05018.55
5.4.320.0170.06018.71
5.4.310.0030.06318.74
5.4.300.0170.05718.43
5.4.290.0300.03718.65
5.4.280.0170.05718.68
5.4.270.0330.03318.78
5.4.260.0100.06718.46
5.4.250.0100.06318.65
5.4.240.0130.05718.82
5.4.230.0230.05018.54
5.4.220.0300.05318.72
5.4.210.0100.05718.55
5.4.200.0130.05316.61
5.4.190.0300.03718.57
5.4.180.0270.06018.68
5.4.170.0200.04718.63
5.4.160.0130.05718.56
5.4.150.0270.04718.72
5.4.140.0230.04716.18
5.4.130.0230.04316.29
5.4.120.0230.04316.25
5.4.110.0230.04016.39
5.4.100.0130.05716.23
5.4.90.0170.05316.33
5.4.80.0100.05716.27
5.4.70.0230.04316.17
5.4.60.0170.05316.21
5.4.50.0200.05716.21
5.4.40.0330.05716.17
5.4.30.0200.05316.43
5.4.20.0200.05316.24
5.4.10.0170.05316.30
5.4.00.0170.05015.92
5.3.290.0300.06014.64
5.3.280.0170.05314.57
5.3.270.0330.06014.65
5.3.260.0170.07714.77
5.3.250.0270.04714.70
5.3.240.0370.05714.64
5.3.230.0270.04314.65
5.3.220.0100.05714.61
5.3.210.0200.05714.62
5.3.200.0130.06314.58
5.3.190.0200.05314.67
5.3.180.0200.05014.64
5.3.170.0200.05014.66
5.3.160.0130.05314.61
5.3.150.0100.06314.63
5.3.140.0130.05714.53
5.3.130.0200.05014.56
5.3.120.0100.06014.68
5.3.110.0130.06014.73
5.3.100.0170.07014.09
5.3.90.0170.05314.04
5.3.80.0070.06314.20
5.3.70.0230.05714.12
5.3.60.0130.05314.00
5.3.50.0200.04714.13
5.3.40.0170.05014.00
5.3.30.0200.05313.91
5.3.20.0170.04713.86
5.3.10.0170.04713.70
5.3.00.0070.06013.78
5.2.170.0070.04711.14
5.2.160.0170.03711.16
5.2.150.0130.04011.13
5.2.140.0130.04011.32
5.2.130.0230.03011.29
5.2.120.0200.03311.14
5.2.110.0200.05011.21
5.2.100.0100.04711.21
5.2.90.0100.04311.25
5.2.80.0070.04711.08
5.2.70.0130.04711.27
5.2.60.0100.04711.09
5.2.50.0200.05011.15
5.2.40.0100.04011.13
5.2.30.0200.04711.07
5.2.20.0170.04311.09
5.2.10.0130.03710.85
5.2.00.0200.03710.75
5.1.60.0130.03010.13
5.1.50.0100.03710.18
5.1.40.0130.04010.11
5.1.30.0170.03310.38
5.1.20.0100.04010.34
5.1.10.0070.04010.13
5.1.00.0130.03010.20
5.0.50.0100.0278.59
5.0.40.0100.0238.41
5.0.30.0100.0478.22
5.0.20.0130.0238.29
5.0.10.0100.0278.18
5.0.00.0130.0378.18
4.4.90.0070.0235.93
4.4.80.0030.0275.85
4.4.70.0070.0275.89
4.4.60.0070.0235.88
4.4.50.0030.0235.88
4.4.40.0070.0375.86
4.4.30.0100.0175.90
4.4.20.0000.0275.91
4.4.10.0000.0275.97
4.4.00.0100.0305.91
4.3.110.0030.0235.81
4.3.100.0130.0135.83
4.3.90.0070.0205.87
4.3.80.0070.0335.78
4.3.70.0000.0275.81
4.3.60.0070.0205.93
4.3.50.0070.0205.83
4.3.40.0070.0335.79
4.3.30.0100.0204.79
4.3.20.0030.0234.79
4.3.10.0000.0274.79
4.3.00.0100.02312.55