3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Simple file uplaod script. * NO WARRANTY. THIS SCRIPT IS ONLY AN EXAMPLE. * INPUT VALIDATION IS MINIMAL. DO NOT USE IN PRODUCTION * * @copyright 2014 Alex Soban * @license http://opensource.org/licenses/MIT * @author Alex Soban <me@soban.co> */ define('TOKEN', '<secure_token>'); define('UPLOADS', __DIR__ . '/uploads/'); define('URL', 'http://www.example.com/uploads/'); function output(array $data = array()) { header('Content-Type: application/json'); echo json_encode($data); exit; } // `name` check is optional if (empty($_POST) || !isset($_POST['image']) || !isset($_POST['token']) || !isset($_POST['name'])) { output(array('error' => 'Invalid input.')); } // `token` verification if ($_POST['token'] !== TOKEN) { output(array('error' => 'Invalid token.')); } // get the filename and contents $filename = trim(preg_replace('/[^\d\w.]+/i', '', $_POST['name'])); $image = base64_decode($_POST['image']); // "upload" the file to our uploads directory if (!file_put_contents(UPLOADS . $filename, $image)) { output(array('error' => 'Failed saving file.')); } // return file public URL output(array('href' => URL . $filename));

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.0130.00718.55
8.3.50.0090.00821.15
8.3.40.0090.00518.67
8.3.30.0120.00318.84
8.3.20.0080.00018.60
8.3.10.0040.00420.35
8.3.00.0040.01223.71
8.2.180.0110.00416.88
8.2.170.0100.01022.96
8.2.160.0000.01420.37
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0090.00019.25
8.2.110.0090.00022.13
8.2.100.0030.00717.91
8.2.90.0000.00819.07
8.2.80.0000.00817.97
8.2.70.0130.00017.12
8.2.60.0040.00417.93
8.2.50.0000.00918.07
8.2.40.0080.00018.09
8.2.30.0030.00519.77
8.2.20.0040.00417.67
8.2.10.0080.00017.63
8.2.00.0000.00817.74
8.1.280.0000.01625.92
8.1.270.0050.00323.99
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00322.38
8.1.230.0060.00620.88
8.1.220.0040.00418.77
8.1.210.0000.00918.94
8.1.200.0040.00817.47
8.1.190.0050.00317.52
8.1.180.0060.00318.10
8.1.170.0030.00618.64
8.1.160.0000.00818.76
8.1.150.0000.00818.55
8.1.140.0060.00317.46
8.1.130.0000.00717.77
8.1.120.0000.00717.45
8.1.110.0050.00317.37
8.1.100.0040.00417.43
8.1.90.0030.00517.38
8.1.80.0000.00817.36
8.1.70.0000.00717.31
8.1.60.0000.00817.53
8.1.50.0030.00517.43
8.1.40.0000.00717.41
8.1.30.0000.00717.61
8.1.20.0040.00417.67
8.1.10.0030.00617.39
8.1.00.0070.00017.29
8.0.300.0000.00819.85
8.0.290.0000.00716.72
8.0.280.0070.00018.44
8.0.270.0030.00317.12
8.0.260.0070.00016.75
8.0.250.0000.00716.91
8.0.240.0030.00516.94
8.0.230.0000.00716.91
8.0.220.0000.00716.89
8.0.210.0000.00816.93
8.0.200.0030.00316.86
8.0.190.0000.00716.95
8.0.180.0040.00416.97
8.0.170.0030.00516.90
8.0.160.0070.00016.80
8.0.150.0040.00416.86
8.0.140.0030.00716.85
8.0.130.0050.00013.39
8.0.120.0040.00416.79
8.0.110.0040.00416.96
8.0.100.0040.00416.83
8.0.90.0070.00016.79
8.0.80.0060.01116.86
8.0.70.0040.00417.00
8.0.60.0000.00716.87
8.0.50.0080.00016.86
8.0.30.0120.00717.14
8.0.20.0070.01217.40
8.0.10.0050.00217.03
8.0.00.0110.00716.86
7.4.330.0060.00013.43
7.4.320.0000.00716.48
7.4.300.0030.00316.47
7.4.290.0000.00716.45
7.4.280.0000.00716.38
7.4.270.0000.00716.50
7.4.260.0000.00513.16
7.4.250.0000.00716.56
7.4.240.0040.00416.38
7.4.230.0030.00316.43
7.4.220.0030.01316.56
7.4.210.0060.01116.47
7.4.200.0000.00716.54
7.4.190.0070.00016.62
7.4.160.0120.00316.69
7.4.150.0080.00917.40
7.4.140.0070.01317.86
7.4.130.0120.00716.43
7.4.120.0080.01016.59
7.4.110.0130.01016.24
7.4.100.0040.01916.78
7.4.90.0090.00916.38
7.4.80.0130.01319.04
7.4.70.0070.00916.48
7.4.60.0000.01716.27
7.4.50.0000.00916.59
7.4.40.0120.00322.27
7.4.30.0090.00916.63
7.4.10.0070.01016.15
7.4.00.0100.00815.67
7.3.330.0050.00013.16
7.3.320.0030.00313.36
7.3.310.0030.00316.32
7.3.300.0030.00316.19
7.3.290.0070.00716.32
7.3.280.0070.01116.30
7.3.270.0040.01317.40
7.3.260.0060.01118.24
7.3.250.0110.01116.33
7.3.240.0090.01216.56
7.3.230.0030.01416.39
7.3.210.0080.00816.34
7.3.200.0120.00619.39
7.3.190.0060.01216.52
7.3.180.0100.00716.52
7.3.170.0100.00616.27
7.3.160.0060.00916.41
7.3.130.0000.02016.44
7.3.120.0100.00715.40
7.3.110.0060.01016.41
7.3.100.0100.00716.41
7.3.90.0130.00316.34
7.3.80.0000.01316.32
7.3.70.0100.00316.24
7.3.60.0040.00816.42
7.3.50.0000.00916.30
7.3.40.0040.00716.38
7.3.30.0040.01116.36
7.3.20.0080.00417.97
7.3.10.0040.00917.49
7.3.00.0060.00817.18
7.2.330.0030.01516.55
7.2.320.0110.00916.56
7.2.310.0110.00816.60
7.2.300.0060.00916.57
7.2.290.0030.01416.33
7.2.260.0070.01416.39
7.2.250.0110.00616.49
7.2.240.0090.00916.59
7.2.230.0090.00616.40
7.2.220.0070.00716.64
7.2.210.0080.00316.43
7.2.200.0090.00916.55
7.2.190.0100.00716.44
7.2.180.0060.00616.53
7.2.170.0090.00616.61
7.2.160.0030.00916.52
7.2.150.0040.00418.15
7.2.140.0030.01018.36
7.2.130.0100.00817.60
7.2.120.0070.00517.53
7.2.110.0020.01217.36
7.2.100.0050.00717.49
7.2.90.0090.00617.37
7.2.80.0070.00717.49
7.2.70.0050.00817.61
7.2.60.0050.00517.58
7.2.50.0050.00517.50
7.2.40.0040.00717.59
7.2.30.0060.00517.62
7.2.20.0100.00717.55
7.2.10.0110.00617.54
7.2.00.0030.01018.21
7.1.330.0040.01417.19
7.1.320.0030.01417.31
7.1.310.0060.00917.31
7.1.300.0040.00417.41
7.1.290.0070.00417.12
7.1.280.0030.01017.29
7.1.270.0070.01017.18
7.1.260.0080.00817.13
7.1.250.0020.01416.54
7.1.240.0040.00717.24
7.1.230.0040.01117.20
7.1.220.0030.01017.42
7.1.210.0070.00417.33
7.1.200.0040.00916.44
7.1.190.0000.00817.16
7.1.180.0100.00317.18
7.1.170.0040.01117.23
7.1.160.0060.00617.17
7.1.150.0030.00617.17
7.1.140.0090.00617.15
7.1.130.0140.00317.14
7.1.120.0080.00317.08
7.1.110.0070.00417.20
7.1.100.0050.00717.60
7.1.90.0070.00717.39
7.1.80.0100.00317.43
7.1.70.0030.01017.07
7.1.60.0120.00818.27
7.1.50.0050.00616.86
7.1.40.0030.00917.25
7.1.30.0090.00917.29
7.1.20.0090.00617.23
7.1.10.0050.00817.18
7.1.00.0030.04119.88
7.0.330.0040.00816.83
7.0.320.0070.00716.95
7.0.310.0060.00917.01
7.0.300.0040.01116.90
7.0.290.0000.01216.83
7.0.280.0050.00316.84
7.0.270.0070.00716.88
7.0.260.0110.00016.80
7.0.250.0040.00816.92
7.0.240.0070.00317.00
7.0.230.0000.00817.05
7.0.220.0110.00317.02
7.0.210.0040.01117.16
7.0.200.0000.01016.65
7.0.190.0030.01017.15
7.0.180.0040.00416.87
7.0.170.0070.00716.98
7.0.160.0030.01316.95
7.0.150.0050.00317.11
7.0.140.0020.04219.53
7.0.130.0000.01416.98
7.0.120.0000.01416.97
7.0.110.0070.00516.99
7.0.100.0090.00616.98
7.0.90.0090.02918.36
7.0.80.0050.02518.40
7.0.70.0050.03518.35
7.0.60.0050.03518.48
7.0.50.0040.05018.61
7.0.40.0070.02917.53
7.0.30.0080.04617.56
7.0.20.0050.03717.54
7.0.10.0070.04517.50
7.0.00.0060.04817.45
5.6.400.0100.00916.12
5.6.390.0030.00815.92
5.6.380.0060.00315.75
5.6.370.0100.00316.23
5.6.360.0100.00015.83
5.6.350.0060.00315.75
5.6.340.0030.00816.09
5.6.330.0090.00916.05
5.6.320.0030.01316.07
5.6.310.0030.01715.97
5.6.300.0030.00715.97
5.6.290.0040.01116.12
5.6.280.0050.04018.56
5.6.270.0140.00316.15
5.6.260.0090.00915.91
5.6.250.0030.00915.88
5.6.240.0110.02718.17
5.6.230.0100.01918.26
5.6.220.0070.04318.21
5.6.210.0050.04518.21
5.6.200.0060.04818.35
5.6.190.0070.02718.45
5.6.180.0050.03818.49
5.6.170.0050.02518.29
5.6.160.0100.02318.38
5.6.150.0080.04518.35
5.6.140.0110.04518.48
5.6.130.0070.04518.52
5.6.120.0050.03218.57
5.6.110.0090.02918.52
5.6.100.0070.04718.50
5.6.90.0050.03618.36
5.6.80.0110.02518.10
5.6.70.0070.02518.02
5.6.60.0070.02318.12
5.6.50.0070.04518.22
5.6.40.0070.02718.05
5.6.30.0070.03818.18
5.6.20.0020.03318.06
5.6.10.0070.02718.10
5.6.00.0040.03918.09
5.5.380.0090.04718.08
5.5.370.0100.04318.06
5.5.360.0050.02518.09
5.5.350.0080.02618.08
5.5.340.0100.03518.52
5.5.330.0100.03818.27
5.5.320.0040.02618.37
5.5.310.0060.03518.31
5.5.300.0050.03518.29
5.5.290.0050.02618.37
5.5.280.0040.02718.23
5.5.270.0050.02918.26
5.5.260.0070.02718.44
5.5.250.0080.03718.33
5.5.240.0090.03017.96
5.5.230.0070.02418.00
5.5.220.0020.02918.03
5.5.210.0020.03117.95
5.5.200.0050.04718.07
5.5.190.0060.02417.91
5.5.180.0040.03117.93
5.5.170.0140.00315.75
5.5.160.0030.03917.97
5.5.150.0020.02717.93
5.5.140.0050.03518.08
5.5.130.0060.04317.95
5.5.120.0060.04317.92
5.5.110.0090.03317.99
5.5.100.0020.02518.05
5.5.90.0040.04417.88
5.5.80.0100.04018.03
5.5.70.0100.04017.90
5.5.60.0070.03017.92
5.5.50.0070.02117.91
5.5.40.0070.02917.94
5.5.30.0100.02317.93
5.5.20.0090.02417.87
5.5.10.0050.04317.79
5.5.00.0050.03417.82
5.4.450.0020.02915.93
5.4.440.0020.03416.04
5.4.430.0090.03715.95
5.4.420.0030.02815.88
5.4.410.0060.04315.72
5.4.400.0050.04115.66
5.4.390.0000.02715.80
5.4.380.0050.02215.78
5.4.370.0070.04015.99
5.4.360.0050.02715.80
5.4.350.0120.03215.76
5.4.340.0060.03115.90
5.4.330.0100.00712.57
5.4.320.0030.03715.96
5.4.310.0020.03115.78
5.4.300.0080.02215.95
5.4.290.0030.03115.70
5.4.280.0060.04515.85
5.4.270.0070.04015.89
5.4.260.0050.02815.76
5.4.250.0020.02315.82
5.4.240.0080.02815.96
5.4.230.0100.03815.95
5.4.220.0050.04215.79
5.4.210.0030.03115.94
5.4.200.0070.04115.88
5.4.190.0070.03615.83
5.4.180.0070.04015.82
5.4.170.0050.02815.81
5.4.160.0070.03715.66
5.4.150.0030.02515.85
5.4.140.0070.03914.58
5.4.130.0040.04014.31
5.4.120.0060.03914.45
5.4.110.0050.02514.64
5.4.100.0040.02714.32
5.4.90.0050.02314.49
5.4.80.0110.03314.57
5.4.70.0050.02714.52
5.4.60.0050.03514.52
5.4.50.0020.02614.51
5.4.40.0100.03814.45
5.4.30.0100.02314.45
5.4.20.0000.02914.49
5.4.10.0050.03514.43
5.4.00.0060.02914.11
5.3.290.0030.02613.84
5.3.280.0070.03813.87
5.3.270.0050.03013.88
5.3.260.0050.04213.91
5.3.250.0090.02513.83
5.3.240.0030.03613.72
5.3.230.0070.04013.76
5.3.220.0070.04313.75
5.3.210.0100.03713.72
5.3.200.0030.04213.75
5.3.190.0050.03413.86
5.3.180.0050.04313.74
5.3.170.0030.03913.94
5.3.160.0080.04013.71
5.3.150.0030.02313.71
5.3.140.0080.03613.73
5.3.130.0040.02813.81
5.3.120.0030.04513.71
5.3.110.0080.03613.76
5.3.100.0070.03013.64
5.3.90.0050.03313.66
5.3.80.0030.04313.47
5.3.70.0060.03113.44
5.3.60.0070.04113.52
5.3.50.0050.03013.46
5.3.40.0120.03813.42
5.3.30.0000.02813.47
5.3.20.0050.04213.39
5.3.10.0020.04313.26
5.3.00.0020.02613.30
5.2.170.0130.04311.21
5.2.160.0030.03011.02
5.2.150.0030.04011.06
5.2.140.0070.02711.29
5.2.130.0000.06711.25
5.2.120.0000.06711.02
5.2.110.0100.03711.23
5.2.100.0100.05311.21
5.2.90.0100.06011.23
5.2.80.0070.05311.12
5.2.70.0030.06311.05
5.2.60.0000.04011.12
5.2.50.0070.05011.03
5.2.40.0000.06311.00
5.2.30.0030.05310.91
5.2.20.0070.05710.96
5.2.10.0070.06010.82
5.2.00.0000.04010.84
5.1.60.0100.04710.11
5.1.50.0030.03310.00
5.1.40.0000.04310.07
5.1.30.0000.04010.48
5.1.20.0070.02310.27
5.1.10.0030.03010.09
5.1.00.0000.03010.07
5.0.50.0030.0208.54
5.0.40.0000.0208.50
5.0.30.0030.0338.25
5.0.20.0030.0178.19
5.0.10.0030.0178.25
5.0.00.0000.0308.21
4.4.90.0070.0178.19
4.4.80.0030.0378.19
4.4.70.0030.0238.19
4.4.60.0000.0338.19
4.4.50.0030.0338.19
4.4.40.0000.0538.19
4.4.30.0000.0278.19
4.4.20.0030.0138.19
4.4.10.0030.0138.19
4.4.00.0030.0238.19
4.3.110.0100.0108.19
4.3.100.0000.0178.19
4.3.90.0070.0108.19
4.3.80.0000.0238.19
4.3.70.0000.0138.19
4.3.60.0030.0138.19
4.3.50.0000.0178.19
4.3.40.0000.0238.19
4.3.30.0030.0138.19
4.3.20.0000.0178.19
4.3.10.0000.0138.19
4.3.00.0000.0178.19

preferences:
47.73 ms | 401 KiB | 5 Q