3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** CONFIG */ $pageConf['title'] = ""; $pageConf['desc'] = ""; $pageConf['keywords'] = ""; /** PAGE SPECIFIC */ set_time_limit(600); /* FUNCTIONS */ function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } function imageThumbnail($inputFileName, $maxSize = 500) { $info = getimagesize($inputFileName); $type = isset($info['type']) ? $info['type'] : $info[2]; // Check support of file type if ( !(imagetypes() & $type) ) { // Server does not support file type return false; } $width = isset($info['width']) ? $info['width'] : $info[0]; $height = isset($info['height']) ? $info['height'] : $info[1]; // Calculate aspect ratio $wRatio = $maxSize / $width; $hRatio = $maxSize / $height; // Using imagecreatefromstring will automatically detect the file type $sourceImage = imagecreatefromstring(file_get_contents($inputFileName)); // Calculate a proportional width and height no larger than the max size. if ( ($width <= $maxSize) && ($height <= $maxSize) ) { // Input is smaller than thumbnail, do nothing return $sourceImage; } elseif ( ($wRatio * $height) < $maxSize ) { // Image is horizontal $tHeight = ceil($wRatio * $height); $tWidth = $maxSize; } else { // Image is vertical $tWidth = ceil($hRatio * $width); $tHeight = $maxSize; } $thumb = imagecreatetruecolor($tWidth, $tHeight); if ( $sourceImage === false ) { // Could not load image return false; } // Copy resampled makes a smooth thumbnail imagecopyresampled($thumb, $sourceImage, 0, 0, 0, 0, $tWidth, $tHeight, $width, $height); imagedestroy($sourceImage); return $thumb; } function imageToFile($im, $fileName, $quality = 80) { if ( !$im || file_exists($fileName) ) { return false; } $ext = strtolower(substr($fileName, strrpos($fileName, '.'))); switch ( $ext ) { case '.gif': imagegif($im, $fileName); break; case '.jpg': case '.jpeg': imagejpeg($im, $fileName, $quality); break; case '.png': imagepng($im, $fileName); break; default: return false; } return true; } /* UPLOAD */ if(isset($_POST['Submit'])) { $done = 0; for ($i = 0; $i < count($_FILES['file']['name']); $i++) { // stop if 10 files successfully done already if ($done >= 10) { echo 'Limit of 10 files at one time reached.'; break; } // read name of file submitted for uploading $file = $_FILES['file']['name'][$i]; // check if (!$image) { continue; } // determine type of file $extension = strtolower(getExtension(stripslashes($_FILES['file']['name'][$i]))); if (($extension == 'jpg') || ($extension == 'jpeg') || ($extension == 'bmp') || ($extension == 'png') || ($extension == 'gif')) { // check filesize if (filesize($_FILES['image']['tmp_name'][$i]) > 10240*1024) { $error = 1; } // check mimetype $fileinfo = getimagesize($_FILES['image']['tmp_name'][$i]); if ($fileinfo['mime'] != 'image/gif' && $fileinfo['mime'] != 'image/jpeg' && $fileinfo['mime'] != 'image/png' && $fileinfo['mime'] != 'image/pjpeg' && isset($fileinfo)) { $error = 1; } // set file type $fileType = 'image'; } else if (($extension == 'mpg') || ($extension == 'mov') || ($extension == 'flv') || ($extension == 'mp4') || ($extension == 'wmv') || ($extension == 'webm') || ($extension == 'mkv') || ($extension == 'ogg')) { // check filesize if (filesize($_FILES['image']['tmp_name'][$i]) > 10240*1024) { $error = 1; } // check mimetype $fileinfo = getimagesize($_FILES['image']['tmp_name'][$i]); if ($fileinfo['mime'] != 'video/mpeg' && $fileinfo['mime'] != 'video/mp4' && $fileinfo['mime'] != 'video/ogg' && $fileinfo['mime'] != 'video/x-ms-wmv' && $fileinfo['mime'] != 'video/webm' && $fileinfo['mime'] != 'video/quicktime' && $fileinfo['mime'] != 'video/x-flv' && $fileinfo['mime'] != 'video/x-matroska' && isset($fileinfo)) { $error = 1; } // set file type $fileType = 'video'; } else { $error = 1; } // upload file to correct directory if empty($error) { $done++; // set paths // set folder path $datepath = date('mY'); $file_path = $_SERVER['DOCUMENT_ROOT'] . '/files/' . $datepath . '/'; $file_thumb_path = $_SERVER['DOCUMENT_ROOT'] . '/files/thumbs/' . $datepath . '/'; // upload to permanent location $file_id = randId(8,0,1); copy($_FILES['image']['tmp_name'][$i], $file_path . $file_id . $extension); // database // $file_id becomes file identifier // associate $file_id with user account // store $filetype // generate thumbnail // image if ($filetype == 'image') { $thumbgen = imageThumbnail($file_path . $file_id . $extension, 150); imagetofile($thumbgen, $file_thumb_path . $file_id . $extension); imagedestroy($thumbgen); } // video if ($filetype == 'video') { // actual size thumbnail (i.e. 640x480) //$file_thumb_path . $file_id . $extension // small thumbnail (150) //$file_thumb_path . $file_id . '-small' . $extension // video strip //$file_thumb_path . $file_id . '-strip' . $extension } } } } else { ?> <form style="margin-left:auto;margin-right:auto;" method="post" enctype="multipart/form-data" action=""> <input type="hidden" name="MAX_FILE_SIZE" value="10485760"> <input type="hidden" name="_mode" value="normal"> <div id="upload_fields"> <input name="file[]" type="file" size="30" alt="file select" multiple> <br><p class="index_intro" style="font-size:10.5px">If your browser only lets you select one file at a time please use the <a href="classic.php" rel="nofollow">classic uploader</a>.</p> </div> <div id="uploading" style="visibility:hidden;height:0px;"><img src="/_assets/images/upload_progress1.gif" alt="Uploading"></div> <input name="Submit" type="submit" id="submit" value="." style="color:#c1c6e1" onclick="uploadprogress('uploading');"> </form> <?php } ?>

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.240.0090.03512.44
5.4.230.0040.04112.43
5.4.220.0090.04312.43
5.4.210.0070.04412.43
5.4.200.0070.04612.43
5.4.190.0070.04612.43
5.4.180.0090.05012.42
5.4.170.0110.04212.43
5.4.160.0070.04512.43
5.4.150.0070.04912.42
5.4.140.0060.04512.12
5.4.130.0050.04512.10
5.4.120.0080.04512.06
5.4.110.0070.04812.06
5.4.100.0060.04512.05
5.4.90.0120.04712.05
5.4.80.0080.04512.06
5.4.70.0070.04212.05
5.4.60.0070.04212.05
5.4.50.0100.04212.05
5.4.40.0060.04312.04
5.4.30.0050.04412.04
5.4.20.0090.04212.03
5.4.10.0080.04212.03
5.4.00.0070.04211.53
5.3.280.0080.04512.71
5.3.270.0050.05012.73
5.3.260.0090.04712.73
5.3.250.0100.04612.73
5.3.240.0070.04712.73
5.3.230.0070.04912.72
5.3.220.0080.04912.69
5.3.210.0070.04512.69
5.3.200.0070.04212.69
5.3.190.0050.03912.69
5.3.180.0030.04112.68
5.3.170.0070.03712.68
5.3.160.0020.04112.68
5.3.150.0070.03812.68
5.3.140.0060.04212.67
5.3.130.0090.04312.67
5.3.120.0050.04612.67
5.3.110.0080.04212.67
5.3.100.0050.04012.15
5.3.90.0060.03812.13
5.3.80.0090.04112.12
5.3.70.0070.04312.12
5.3.60.0110.03812.10
5.3.50.0110.03812.05
5.3.40.0070.04312.05
5.3.30.0070.04112.01
5.3.20.0080.04011.79
5.3.10.0100.03911.75
5.3.00.0100.03911.74

preferences:
140.69 ms | 1394 KiB | 7 Q