3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Upload has a limit of 10 mb * @param string $dir $_SERVER['DOCUMENT_ROOT'] * @param string $path Path do you want to upload the file * @param string $filetype jpg|jpeg|gif|png|doc|docx|txt|rtf|pdf|xls|xlsx|ppt|pptx * @param array $_FILES An associative array of items uploaded to the current script via the HTTP POST method. * @return string ?$fileName:False */ function uploadFiles($dir, $path, $filetype, $_FILES) { $dir_base = "{$dir}{$path}"; $dateadded = date('ynj_Gis-'); $rEFileTypes = "/^\.($filetype){1}$/i"; $MAXIMUM_FILESIZE = 10 * 1024 * 1024; // UPLOAD IMAGES $isFile = is_uploaded_file($_FILES['file']['tmp_name']); if ($isFile) { $safe_filename = $dateadded . preg_replace(array('/\s+/', '/[^-\.\w]+/'), array('_', ''), trim($_FILES['file']['name'])); if ($_FILES['file']['size'] <= $MAXIMUM_FILESIZE && preg_match($rEFileTypes, strrchr($safe_filename, '.'))) { $isMove = move_uploaded_file($_FILES['file']['tmp_name'], $dir_base . $safe_filename); } } if ($isMove) { return $safe_filename; } else { return false; } }

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.200.0030.04112.39
5.4.190.0200.04412.38
5.4.180.0160.04712.38
5.4.170.0250.04212.39
5.4.160.0170.04812.39
5.4.150.0190.05112.39
5.4.140.0320.09612.07
5.4.130.0160.05212.06
5.4.120.0200.04512.02
5.4.110.0150.04512.01
5.4.100.0410.08112.01
5.4.90.0160.04512.01
5.4.80.0140.05012.01
5.4.70.0180.04112.00
5.4.60.0140.04612.00
5.4.50.0200.04112.00
5.4.40.0270.06311.99
5.4.30.0190.04011.99
5.4.20.0120.04911.98
5.4.10.0270.06311.99
5.4.00.0130.04511.48
5.3.290.0030.04112.80
5.3.280.0090.04512.71
5.3.270.0140.05312.72
5.3.260.0160.04912.72
5.3.250.0220.04212.72
5.3.240.0220.04212.72
5.3.230.0200.04312.71
5.3.220.0180.04112.68
5.3.210.0180.04612.68
5.3.200.0180.04412.68
5.3.190.0200.04312.68
5.3.180.0130.05012.67
5.3.170.0170.04512.67
5.3.160.0130.04712.68
5.3.150.0310.09112.67
5.3.140.0200.04012.66
5.3.130.0150.04812.66
5.3.120.0130.04812.65
5.3.110.0170.04412.66
5.3.100.0220.04012.13
5.3.90.0240.04012.12
5.3.80.0160.04512.11
5.3.70.0160.04812.11
5.3.60.0200.04112.09
5.3.50.0130.04812.03
5.3.40.0350.08812.03
5.3.30.0120.04912.00
5.3.20.0180.04411.78
5.3.10.0160.04111.74
5.3.00.0130.04511.72

preferences:
142.16 ms | 1394 KiB | 7 Q