3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fName = "item.txt"; // 1 $fp = fopen($fName, "r") or die("File not found/opened!"); // 2 $lineCount = 0; while ($lineIn = fgets($fp) ) { // 3 print("$lineIn <br/>"); $lineCount++; } print ("line count = $lineCount<br/><br/>"); fclose($fp); $fp = fopen($fName, "r"); // 4 $lineIn = fgets($fp); $id = substr($lineIn, 0, 5); $name = substr($lineIn, 6, 14); $cost = substr($lineIn, 21, 6); $qty = substr($lineIn, 28, 1); print("<pre>"); print("$id\t$name\t$cost\t$qty\n\n"); fclose($fp); $fName = "item.csv"; $fp = fopen($fName, "r") or die("File not found/opened!"); $delimiter = ','; $totalCost = 0.00; print("<font face = \"Lucida Console\" size = \"3\" >"); printf("%30s", "Item Inventory\n"); printf("%5s \t %-14s \t %6s \t %-3s\n", "id", "name", "cost", "qty"); while ($item = fgetcsv($fp, $delimiter) ) { // 5 $id = $item[0]; $name = $item[1]; $cost = $item[2]; $qty = $item[3]; printf("%5d \t %-14s \t %6.2f \t %1d\n", $id, $name, $cost, $qty); $totalCost += $cost; } printf("%31s %7.2f", "total cost:", $totalCost); fclose($fp); ?>

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).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0140.00717.13
8.3.50.0110.00822.94
8.3.40.0000.01518.60
8.3.30.0080.00619.17
8.3.20.0020.00520.37
8.3.10.0070.00418.81
8.3.00.0000.00819.38
8.2.180.0180.00316.75
8.2.170.0070.00722.96
8.2.160.0000.01420.38
8.2.150.0070.00024.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0080.00021.11
8.2.110.0040.00420.93
8.2.100.0060.00617.91
8.2.90.0040.00419.28
8.2.80.0000.00817.97
8.2.70.0030.00617.63
8.2.60.0000.00917.93
8.2.50.0000.00918.10
8.2.40.0040.00420.47
8.2.30.0050.00219.37
8.2.20.0050.00217.79
8.2.10.0000.00718.23
8.2.00.0060.00317.98
8.1.280.0040.01125.92
8.1.270.0040.00423.88
8.1.260.0070.00026.35
8.1.250.0070.00028.09
8.1.240.0000.00922.52
8.1.230.0060.00617.89
8.1.220.0080.00017.76
8.1.210.0110.00018.77
8.1.200.0060.00317.35
8.1.190.0040.00417.35
8.1.180.0080.00018.10
8.1.170.0090.00018.62
8.1.160.0040.00422.18
8.1.150.0040.00418.81
8.1.140.0080.00017.51
8.1.130.0000.00717.88
8.1.120.0000.00717.47
8.1.110.0000.00817.54
8.1.100.0030.00517.56
8.1.90.0030.00417.41
8.1.80.0000.00717.43
8.1.70.0040.00417.40
8.1.60.0000.00817.62
8.1.50.0080.00017.54
8.1.40.0070.00017.44
8.1.30.0060.00317.69
8.1.20.0000.00717.75
8.1.10.0000.00817.46
8.1.00.0000.00817.51
8.0.300.0080.00019.94
8.0.290.0080.00016.88
8.0.280.0050.00218.59
8.0.270.0070.00017.38
8.0.260.0000.00617.37
8.0.250.0070.00017.09
8.0.240.0050.00517.07
8.0.230.0030.00317.18
8.0.220.0000.00817.07
8.0.210.0040.00417.09
8.0.200.0000.00717.14
8.0.190.0000.00716.98
8.0.180.0020.00516.98
8.0.170.0030.00517.08
8.0.160.0000.00717.12
8.0.150.0000.00817.02
8.0.140.0000.00717.11
8.0.130.0030.00313.48
8.0.120.0000.00816.94
8.0.110.0040.00416.99
8.0.100.0040.00416.94
8.0.90.0040.00417.04
8.0.80.0090.01317.02
8.0.70.0040.00417.07
8.0.60.0040.00416.95
8.0.50.0040.00416.88
8.0.30.0100.01017.11
8.0.20.0070.01217.40
8.0.10.0050.00217.00
8.0.00.0060.01416.74
7.4.330.0000.00515.00
7.4.320.0000.00616.66
7.4.300.0030.00316.51
7.4.290.0070.00016.65
7.4.280.0030.00916.64
7.4.270.0040.00416.67
7.4.260.0000.00716.63
7.4.250.0040.00416.57
7.4.240.0060.00116.67
7.4.230.0070.00016.73
7.4.220.0150.00316.64
7.4.210.0110.00316.58
7.4.200.0000.00716.37
7.4.160.0060.01216.36
7.4.150.0190.00017.40
7.4.140.0130.00717.86
7.4.130.0100.00716.55
7.4.120.0060.01116.61
7.4.110.0160.00016.57
7.4.100.0040.01216.59
7.4.90.0170.00316.57
7.4.80.0070.01119.39
7.4.70.0070.01016.57
7.4.60.0100.00716.71
7.4.50.0030.00616.41
7.4.40.0030.01316.35
7.4.30.0130.00316.63
7.4.00.0070.01014.91
7.3.330.0000.00613.17
7.3.320.0070.00013.21
7.3.310.0030.00316.18
7.3.300.0000.00816.31
7.3.290.0090.00616.26
7.3.280.0090.00616.30
7.3.270.0070.01417.40
7.3.260.0170.00716.25
7.3.250.0090.00916.44
7.3.240.0030.01316.21
7.3.230.0090.00916.39
7.3.210.0100.01316.29
7.3.200.0120.00919.39
7.3.190.0090.01216.48
7.3.180.0030.01316.15
7.3.170.0000.01716.46
7.3.160.0090.00616.43
7.3.120.0070.00914.91
7.3.110.0030.01414.91
7.3.100.0050.01014.58
7.3.90.0130.00214.75
7.3.80.0080.00614.59
7.3.70.0050.00814.80
7.3.60.0100.00614.82
7.3.50.0110.00214.77
7.3.40.0060.00714.80
7.3.30.0060.00514.68
7.3.20.0060.00816.59
7.3.10.0070.00516.46
7.3.00.0040.01016.62
7.2.330.0200.00316.69
7.2.320.0090.00916.54
7.2.310.0160.00316.56
7.2.300.0070.01416.62
7.2.290.0030.01316.50
7.2.250.0080.00915.09
7.2.240.0100.01014.99
7.2.230.0110.00515.02
7.2.220.0040.00615.14
7.2.210.0050.01115.09
7.2.200.0100.00315.12
7.2.190.0030.01315.06
7.2.180.0060.00914.87
7.2.170.0050.00615.15
7.2.130.0070.00716.59
7.2.120.0000.01716.99
7.2.110.0000.01316.89
7.2.100.0070.00716.96
7.2.90.0030.01016.90
7.2.80.0080.00316.70
7.2.70.0040.01216.98
7.2.60.0040.00816.96
7.2.50.0030.00917.02
7.2.40.0030.00617.04
7.2.30.0040.00816.80
7.2.20.0000.01516.63
7.2.10.0030.01016.82
7.2.00.0050.00818.05
7.1.330.0020.01115.77
7.1.320.0030.00815.76
7.1.310.0130.00215.73
7.1.300.0110.00215.49
7.1.290.0020.01115.71
7.1.280.0050.00515.61
7.1.270.0080.00815.83
7.1.260.0080.00515.63
7.1.250.0040.01115.74
7.1.100.0000.01118.09
7.1.70.0030.01017.15
7.1.60.0060.01819.61
7.1.50.0120.01616.91
7.1.00.0100.07022.44
7.0.200.0040.00416.50
7.0.140.0130.06322.00
7.0.60.0070.08719.85
7.0.50.0030.05017.89
7.0.40.0100.07020.04
7.0.30.0500.07720.17
7.0.20.0200.04020.16
7.0.10.0230.08320.04
7.0.00.0100.04320.18
5.6.280.0000.07721.11
5.6.210.0030.08320.53
5.6.200.0130.05718.22
5.6.190.0070.04320.39
5.6.180.0300.05320.43
5.6.170.0230.04720.33
5.6.160.0030.08020.41
5.6.150.0000.08718.08
5.6.140.0000.09018.12
5.6.130.0000.07718.13
5.6.120.0130.04321.12
5.6.110.0100.08320.98
5.6.100.0100.08021.04
5.6.90.0070.08321.11
5.6.80.0100.07020.39
5.6.70.4200.03320.48
5.5.350.0130.08020.41
5.5.340.0030.04717.97
5.5.330.0030.06320.21
5.5.320.0230.04020.28
5.5.310.0230.04020.23
5.5.300.0030.04718.02
5.5.290.0070.05317.98
5.5.280.0030.04720.79
5.5.270.0030.08320.73
5.5.260.0100.07720.87
5.5.250.0070.07320.62
5.5.240.3870.03320.24
5.4.450.0300.04019.43
5.4.440.0070.05019.10
5.4.430.0200.03719.48
5.4.420.0230.04319.13
5.4.410.0200.04319.33
5.4.400.0500.04318.89
5.4.390.0600.04019.13
5.4.380.0470.07018.46
5.4.370.0300.05318.73
5.4.360.0430.06018.63
5.4.350.0400.05718.73
5.4.340.0530.04018.70
5.4.320.0040.03812.47
5.4.310.0070.03612.47
5.4.300.0070.03512.48
5.4.290.0060.03712.47
5.4.280.0070.03412.37
5.4.270.0050.03712.37
5.4.260.0030.04212.37
5.4.250.0060.04112.37
5.4.240.0050.04112.37
5.4.230.0070.04112.36
5.4.220.0100.03412.36
5.4.210.0060.04312.36
5.4.200.0040.04512.36
5.4.190.0060.03912.36
5.4.180.0070.04412.36
5.4.170.0060.04212.37
5.4.160.0080.03912.36
5.4.150.0080.03512.36
5.4.140.0060.04612.04
5.4.130.0050.03812.03
5.4.120.0050.03611.99
5.4.110.0060.03511.99
5.4.100.0080.03311.99
5.4.90.0080.03511.99
5.4.80.0060.04011.98
5.4.70.0070.03411.98
5.4.60.0060.03611.98
5.4.50.0070.03611.98
5.4.40.0060.04111.96
5.4.30.0060.03911.96
5.4.20.0120.03411.96
5.4.10.0080.03211.96
5.4.00.0060.03511.46
5.3.290.0060.04012.80
5.3.280.0020.04212.71
5.3.270.0070.03912.72
5.3.260.0050.04112.72
5.3.250.0110.03312.72
5.3.240.0110.04112.72
5.3.230.0100.04412.71
5.3.220.0110.03912.68
5.3.210.0100.04012.68
5.3.200.0040.04212.68
5.3.190.0100.03712.68
5.3.180.0110.03312.67
5.3.170.0080.04212.67
5.3.160.0120.03512.67
5.3.150.0090.03912.68
5.3.140.0050.04012.66
5.3.130.0060.04212.66
5.3.120.0080.03712.65
5.3.110.0060.03812.66
5.3.100.0060.03712.12
5.3.90.0040.03912.09
5.3.80.0080.03612.08
5.3.70.0060.03612.07
5.3.60.0080.03312.06
5.3.50.0080.03412.01
5.3.40.0060.03612.01
5.3.30.0050.03611.97
5.3.20.0060.03611.75
5.3.10.0070.03411.71
5.3.00.0070.03711.70
5.2.170.0060.0419.21
5.2.160.0080.0299.21
5.2.150.0050.0319.21
5.2.140.0050.0309.20
5.2.130.0050.0289.17
5.2.120.0040.0299.16
5.2.110.0060.0299.17
5.2.100.0030.0329.16
5.2.90.0080.0269.16
5.2.80.0040.0319.16
5.2.70.0040.0319.16
5.2.60.0060.0309.11
5.2.50.0030.0349.08
5.2.40.0090.0299.06
5.2.30.0050.0299.04
5.2.20.0040.0309.03
5.2.10.0060.0268.95
5.2.00.0050.0308.81
5.1.60.0020.0278.10
5.1.50.0040.0258.10
5.1.40.0020.0268.08
5.1.30.0050.0258.43
5.1.20.0060.0258.45
5.1.10.0070.0248.18
5.1.00.0040.0278.18
5.0.50.0070.0216.65
5.0.40.0030.0266.51
5.0.30.0040.0316.33
5.0.20.0070.0166.30
5.0.10.0040.0206.28
5.0.00.0060.0286.27
4.4.90.0020.0164.78
4.4.80.0020.0164.75
4.4.70.0010.0194.75
4.4.60.0050.0154.76
4.4.50.0050.0144.77
4.4.40.0040.0244.71
4.4.30.0040.0144.76
4.4.20.0020.0164.84
4.4.10.0030.0154.85
4.4.00.0020.0254.75
4.3.110.0030.0164.67
4.3.100.0030.0184.67
4.3.90.0060.0144.63
4.3.80.0060.0214.58
4.3.70.0010.0174.63
4.3.60.0030.0154.63
4.3.50.0020.0164.63
4.3.40.0060.0214.53
4.3.30.0030.0163.33
4.3.20.0030.0153.30
4.3.10.0020.0153.26
4.3.00.0000.01718.16

preferences:
42.01 ms | 401 KiB | 5 Q