3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * upload.php * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ #!! IMPORTANT: #!! this file is just an example, it doesn't incorporate any security checks and #!! is not recommended to be used in production environment as it is. Be sure to #!! revise it and customize to your needs. // Make sure file is not cached (as it happens for example on iOS devices) header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); /* // Support CORS header("Access-Control-Allow-Origin: *"); // other CORS headers if any... if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { exit; // finish preflight CORS requests here } */ // 5 minutes execution time @set_time_limit(5 * 60); // Uncomment this one to fake upload time // usleep(5000); // Settings //$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload"; $targetDir = 'uploads'; $cleanupTargetDir = true; // Remove old files $maxFileAge = 5 * 3600; // Temp file age in seconds // Create target dir if (!file_exists($targetDir)) { @mkdir($targetDir); } // Get a file name if (isset($_REQUEST["name"])) { $fileName = $_REQUEST["name"]; } elseif (!empty($_FILES)) { $fileName = $_FILES["file"]["name"]; } else { $fileName = uniqid("file_"); } public static function normalizeString ($str = '') { $str = strip_tags($str); $str = preg_replace('/[\r\n\t ]+/', ' ', $str); $str = preg_replace('/[\"\*\/\:\<\>\?\'\|]+/', ' ', $str); $str = strtolower($str); $str = html_entity_decode( $str, ENT_QUOTES, "utf-8" ); $str = htmlentities($str, ENT_QUOTES, "utf-8"); $str = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $str); $str = str_replace(' ', '-', $str); $str = rawurlencode($str); $str = str_replace('%', '-', $str); return $str; } $filename = $this->normalizeString($filename) $filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName; // Chunking might be enabled $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0; // Remove old temp files if ($cleanupTargetDir) { if (!is_dir($targetDir) || !$dir = opendir($targetDir)) { die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}'); } while (($file = readdir($dir)) !== false) { $tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file; // If temp file is current file proceed to the next if ($tmpfilePath == "{$filePath}.part") { continue; } // Remove temp file if it is older than the max age and is not the current file if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge)) { @unlink($tmpfilePath); } } closedir($dir); } // Open temp file if (!$out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb")) { die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); } if (!empty($_FILES)) { if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) { die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}'); } // Read binary input stream and append it to temp file if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) { die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); } } else { if (!$in = @fopen("php://input", "rb")) { die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); } } while ($buff = fread($in, 4096)) { fwrite($out, $buff); } @fclose($out); @fclose($in); // Check if file has been uploaded if (!$chunks || $chunk == $chunks - 1) { // Strip the temp .part suffix off rename("{$filePath}.part", $filePath); } // Return Success JSON-RPC response die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');

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.6.50.0100.07017.57
5.6.40.0100.07717.47
5.6.30.0000.06017.54
5.6.20.0100.06017.53
5.6.10.0030.05317.54
5.6.00.0100.07717.50
5.5.210.0130.05017.43
5.5.200.0130.05017.32
5.5.190.0100.03717.34
5.5.180.0030.05017.30
5.5.160.0100.07717.27
5.5.150.0000.08317.37
5.5.140.0030.05017.33
5.5.130.0070.04317.26
5.5.120.0070.08017.41
5.5.110.0070.05717.30
5.5.100.0130.07017.20
5.5.90.0070.04317.23
5.5.80.0000.08017.29
5.5.70.0070.08017.23
5.5.60.0030.08017.26
5.5.50.0030.04017.32
5.5.40.0100.03017.31
5.5.30.0030.03717.32
5.5.20.0030.04017.18
5.5.10.0030.04017.21
5.5.00.0030.03717.22
5.4.370.0170.06318.96
5.4.360.0000.08719.14
5.4.350.0170.06018.98
5.4.340.0100.03319.27
5.4.320.0070.06019.06
5.4.310.0130.07319.14
5.4.300.0100.06019.13
5.4.290.0030.08018.95
5.4.280.0070.08019.11
5.4.270.0070.06319.06
5.4.260.0100.06019.09
5.4.250.0100.05019.01
5.4.240.0070.08019.03
5.4.230.0070.06319.13
5.4.220.0000.05719.04
5.4.210.0070.06318.98
5.4.200.0000.04019.04
5.4.190.0070.04719.26
5.4.180.0070.04019.09
5.4.170.0000.04019.09
5.4.160.0070.03319.02
5.4.150.0030.03719.25
5.4.140.0070.03016.29
5.4.130.0070.03016.38
5.4.120.0030.05016.30
5.4.110.0030.03716.38
5.4.100.0030.03316.41
5.4.90.0030.05316.39
5.4.80.0070.03716.39
5.4.70.0130.02316.57
5.4.60.0070.03316.43
5.4.50.0030.03316.36
5.4.40.0030.03316.62
5.4.30.0030.03316.36
5.4.20.0030.03316.46
5.4.10.0000.03716.45
5.4.00.0000.03715.83
5.3.290.0070.06014.63
5.3.280.0130.05714.57
5.3.270.0100.03014.60
5.3.260.0100.03014.43
5.3.250.0000.03714.53
5.3.240.0070.03314.58
5.3.230.0000.04014.57
5.3.220.0000.04014.55
5.3.210.0000.04014.39
5.3.200.0030.04714.39
5.3.190.0000.04014.65
5.3.180.0000.04014.52
5.3.170.0070.04014.54
5.3.160.0070.03014.65
5.3.150.0030.03314.55
5.3.140.0070.03014.52
5.3.130.0000.04314.47
5.3.120.0030.03714.50
5.3.110.0070.03314.47
5.3.100.0030.03713.82
5.3.90.0000.03713.98
5.3.80.0100.02713.94
5.3.70.0030.04314.01
5.3.60.0070.03013.95
5.3.50.0000.03713.71
5.3.40.0030.03713.89
5.3.30.0030.03313.89
5.3.20.0000.03713.64
5.3.10.0070.03013.45
5.3.00.0070.07013.73

preferences:
140.58 ms | 1394 KiB | 7 Q