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)
5.4.280.0200.07019.17
5.4.270.0170.04019.04
5.4.260.0230.07018.93
5.4.250.0230.04319.17
5.4.240.0230.03318.99
5.4.230.0230.07019.04
5.4.220.0270.07019.22
5.4.210.0230.06319.12
5.4.200.0170.05319.10
5.4.190.0130.05319.16
5.4.180.0230.06019.25
5.4.170.0170.07319.08
5.4.160.0170.05319.09
5.4.150.0200.05019.13
5.4.140.0300.04716.36
5.4.130.0070.05316.34
5.4.120.0370.03716.35
5.4.110.0270.04316.45
5.4.100.0200.03316.48
5.4.90.0370.02716.48
5.4.80.0170.03316.51
5.4.70.0130.03716.50
5.4.60.0130.04016.46
5.4.50.0130.03316.41
5.4.40.0070.04016.53
5.4.30.0130.03716.42
5.4.20.0100.04316.52
5.4.10.0070.04016.45
5.4.00.0070.04015.89
5.3.280.0200.04314.65
5.3.270.0230.06314.61
5.3.260.0270.06014.62
5.3.250.0270.06714.63
5.3.240.0230.06714.65
5.3.230.0170.04014.60
5.3.220.0200.07314.61
5.3.210.0200.06714.57
5.3.200.0230.04014.61
5.3.190.0170.03714.56
5.3.180.0130.03714.61
5.3.170.0170.03314.62
5.3.160.0170.03014.57
5.3.150.0170.03314.61
5.3.140.0100.04014.71
5.3.130.0170.05714.55
5.3.120.0070.04314.54
5.3.110.0170.03314.56
5.3.100.0170.03314.05
5.3.90.0100.03714.07
5.3.80.0130.03314.17
5.3.70.0100.03714.07
5.3.60.0170.03014.08
5.3.50.0130.03713.87
5.3.40.0230.02313.86
5.3.30.0170.03713.79
5.3.20.0130.03313.68
5.3.10.0130.03313.66
5.3.00.0130.04313.67

preferences:
145.05 ms | 1394 KiB | 7 Q