3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Multiupload extends MY_Controller { /* ----------------------------------------------------------------------------------- * It's actualy not my own source, but I just want to share & bookmark it here ;) * * Thanks to Anggy Trisnawan * Url: http://anggytrisnawan.com/blog/2012/07/21/upload-multiple-file-codeigniter * ----------------------------------------------------------------------------------- */ function __construct() { parent::__construct(); // load the libraries at first $this->load->library('image_lib'); $this->load->helper(array('form', 'url')); } // front view function index() { /* ----------------------------------------------------------------------------------- * It's what you need for the 'upload' view * ----------------------------------------------------------------------------------- * <?php echo form_open_multipart('upload/do_upload');?> * * <!-- make sure you give an array (userfile[]) to the "name" attribute and have attribute "multiple" on it --> * <?php echo form_input( array( 'name'=>'userfile[]', 'multiple'=>true ) ); ?><br /> * * <!-- just, another submit button --> * <?php echo form_submit('submit', 'Upload'); ?> * * <!-- well, close the form --> * <?php echo form_close();?> * ----------------------------------------------------------------------------------- */ $data['multiupload'] = "multiupload"; // Controller $data['view'] = "form_multiupload"; // View $data['module'] = "multiupload"; // Controller $data['error'] = ' '; echo Modules::run('template/staff', $data); } // Upload & Resize in action function do_upload() { $upload_conf = array( 'upload_path' => realpath('assets/doc/img/real/'), 'allowed_types' => 'gif|jpg|png|JPEG|JPG', 'max_size' => '30000', 'encrypt_name' => TRUE, 'overwrite' => TRUE, ); $this->load->library('upload', $upload_conf); //$this->upload->initialize($upload_conf); foreach ($_FILES['userfile'] as $key => $val) { $i = 1; foreach ($val as $v) { $field_name = "file_" . $i; $_FILES[$field_name][$key] = $v; $i++; } } // Unset the useless one ;) unset($_FILES['userfile']); foreach ($_FILES as $field_name => $file) { if (!$this->upload->do_upload($field_name)) { echo $this->image_lib->display_errors(); } else { $upload_data = $this->upload->data(); $ori = $upload_data['file_name']; $mr = $upload_data['file_path'] . $ori; $this->watermarking($mr); //this is the larger image $config['image_library'] = 'gd2'; $config['source_image'] = $upload_data['full_path']; $config['new_image'] = 'assets/doc/img/full/' . $upload_data['file_name']; $config['maintain_ratio'] = TRUE; $config['width'] = 0; $config['height'] = 0; $this->image_lib->initialize($config); $this->image_lib->resize(); $this->image_lib->clear(); //this is the larger image $config['image_library'] = 'gd2'; $config['source_image'] = $upload_data['full_path']; $config['new_image'] = 'assets/doc/img/medium/' . $upload_data['file_name']; $config['maintain_ratio'] = TRUE; $config['width'] = 342; $config['height'] = 342; $this->image_lib->initialize($config); $this->image_lib->resize(); $this->image_lib->clear(); //small image $config['image_library'] = 'gd2'; $config['source_image'] = $upload_data['full_path']; $config['new_image'] = 'assets/doc/img/small/' . $upload_data['file_name']; $config['maintain_ratio'] = TRUE; $config['width'] = 152; $config['height'] = 152; $this->image_lib->initialize($config); $this->image_lib->resize(); $this->image_lib->clear(); //cropped thumbnail $config['image_library'] = 'gd2'; $config['source_image'] = $upload_data['full_path']; $config['new_image'] = 'assets/doc/img/thumbnails/' . $upload_data['file_name']; $config['maintain_ratio'] = TRUE; $config['width'] = 62; $config['height'] = 62; $this->image_lib->initialize($config); $this->image_lib->resize(); $this->image_lib->clear(); // do it! if (!$this->image_lib->resize()) { // if got fail. //$error['resize'][] = $this->image_lib->display_errors(); echo $this->image_lib->display_errors(); } else { // otherwise, put each upload data to an array. $success[] = $upload_data; } } } // see what we get if (count($error > 0)) { $data['error'] = $error; } else { $data['success'] = $upload_data; } $data['multiupload'] = "multiupload"; // Controller $data['view'] = "index_multiupload"; // View $data['module'] = "multiupload"; // Controller $data['error'] = ' '; dump($this->upload->data()); echo Modules::run('template/staff', $data); } } /* End of File: multiupload.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)
8.3.60.0070.01018.30
8.3.50.0160.00321.96
8.3.40.0040.01118.97
8.3.30.0070.00718.99
8.3.20.0040.00420.44
8.3.10.0040.00421.86
8.3.00.0080.00022.44
8.2.180.0080.00816.63
8.2.170.0110.00722.96
8.2.160.0030.01020.86
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0080.00019.36
8.2.110.0100.00022.26
8.2.100.0060.00619.57
8.2.90.0040.00419.16
8.2.80.0030.00518.16
8.2.70.0040.00417.73
8.2.60.0040.00818.18
8.2.50.0040.00818.07
8.2.40.0060.00318.16
8.2.30.0040.00418.03
8.2.20.0050.00217.81
8.2.10.0080.00019.59
8.2.00.0000.00717.84
8.1.280.0070.01025.92
8.1.270.0060.00322.17
8.1.260.0070.00026.35
8.1.250.0050.00328.09
8.1.240.0070.00323.92
8.1.230.0090.00319.22
8.1.220.0080.00017.88
8.1.210.0050.00318.77
8.1.200.0070.00317.35
8.1.190.0040.00417.43
8.1.180.0060.00318.10
8.1.170.0040.00418.59
8.1.160.0000.00921.98
8.1.150.0040.00418.64
8.1.140.0080.00017.53
8.1.130.0040.00417.82
8.1.120.0040.00417.41
8.1.110.0050.00317.38
8.1.100.0040.00417.46
8.1.90.0000.00717.37
8.1.80.0000.00817.46
8.1.70.0070.00017.44
8.1.60.0060.00317.63
8.1.50.0040.00417.48
8.1.40.0040.00417.45
8.1.30.0030.00517.67
8.1.20.0040.00417.67
8.1.10.0080.00017.56
8.1.00.0070.00017.38
8.0.300.0080.00018.77
8.0.290.0000.00717.30
8.0.280.0000.00718.44
8.0.270.0030.00317.21
8.0.260.0000.00716.82
8.0.250.0000.00716.93
8.0.240.0040.00417.02
8.0.230.0030.00416.92
8.0.220.0040.00417.01
8.0.210.0030.00317.02
8.0.200.0000.00716.98
8.0.190.0050.00317.08
8.0.180.0000.00717.00
8.0.170.0040.00417.03
8.0.160.0000.00717.02
8.0.150.0000.00717.02
8.0.140.0040.00417.01
8.0.130.0060.00013.36
8.0.120.0040.00417.02
8.0.110.0000.00816.90
8.0.100.0040.00416.88
8.0.90.0080.00016.89
8.0.80.0090.00616.91
8.0.70.0050.00316.95
8.0.60.0000.00716.86
8.0.50.0070.00016.95
8.0.30.0080.01517.33
8.0.20.0090.01617.40
8.0.10.0040.00416.98
8.0.00.0080.00916.77
7.4.330.0060.00015.00
7.4.320.0070.00016.56
7.4.300.0000.00716.56
7.4.290.0030.00316.55
7.4.280.0040.00416.61
7.4.270.0030.00716.49
7.4.260.0030.00616.58
7.4.250.0050.00216.56
7.4.240.0010.00616.56
7.4.230.0030.00316.54
7.4.220.0120.00316.54
7.4.210.0060.01016.51
7.4.200.0030.00316.41
7.4.190.0040.00416.53
7.4.160.0030.01416.43
7.4.150.0100.00717.40
7.4.140.0070.01517.86
7.4.130.0070.01016.57
7.4.120.0100.00716.73
7.4.110.0070.01016.42
7.4.100.0120.00416.54
7.4.90.0060.01616.42
7.4.80.0070.01019.39
7.4.70.0110.00716.57
7.4.60.0070.01016.53
7.4.50.0040.00416.45
7.4.40.0040.01122.77
7.4.30.0110.00616.66
7.4.10.0100.01014.70
7.4.00.0080.00914.95
7.3.330.0030.00313.20
7.3.320.0000.00613.20
7.3.310.0000.00716.21
7.3.300.0030.00316.31
7.3.290.0030.01016.32
7.3.280.0100.00816.31
7.3.270.0100.00717.40
7.3.260.0060.01716.20
7.3.250.0090.00916.42
7.3.240.0100.00716.41
7.3.230.0030.01616.49
7.3.210.0060.01116.48
7.3.200.0120.00616.58
7.3.190.0140.00316.48
7.3.180.0130.01016.50
7.3.170.0130.00316.52
7.3.160.0100.00716.47
7.3.130.0120.00614.57
7.3.120.0080.01014.84
7.3.110.0060.01214.73
7.3.100.0040.01114.79
7.3.90.0050.01014.80
7.3.80.0090.00414.69
7.3.70.0030.01014.67
7.3.60.0060.00714.70
7.3.50.0080.00614.68
7.3.40.0040.00914.75
7.3.30.0050.01114.79
7.3.20.0030.01316.46
7.3.10.0090.00816.38
7.3.00.0060.00816.48
7.2.330.0120.00616.74
7.2.320.0130.01016.70
7.2.310.0070.01016.76
7.2.300.0070.01016.64
7.2.290.0130.00816.77
7.2.260.0040.01514.61
7.2.250.0030.01415.10
7.2.240.0080.00814.95
7.2.230.0070.00915.04
7.2.220.0050.01015.03
7.2.210.0070.00815.14
7.2.200.0030.01014.97
7.2.190.0080.00815.02
7.2.180.0070.00515.01
7.2.170.0040.00914.98
7.2.160.0060.00914.99
7.2.150.0100.00616.71
7.2.140.0080.00816.63
7.2.130.0100.00616.83
7.2.120.0080.00216.79
7.2.110.0080.00616.71
7.2.100.0080.00516.75
7.2.90.0060.00616.41
7.2.80.0050.01316.66
7.2.70.0050.01116.69
7.2.60.0070.00716.55
7.2.50.0050.00916.61
7.2.40.0060.00916.71
7.2.30.0070.00616.85
7.2.20.0060.00616.69
7.2.10.0070.00516.43
7.2.00.0030.01017.60
7.1.330.0060.00815.47
7.1.320.0050.01115.67
7.1.310.0050.01015.65
7.1.300.0090.00415.69
7.1.290.0070.00415.60
7.1.280.0030.00915.60
7.1.270.0060.00715.75
7.1.260.0040.00815.61
7.1.250.0050.00815.68
7.1.240.0040.01115.20
7.1.230.0070.00315.22
7.1.220.0060.00615.21
7.1.210.0030.00915.25
7.1.200.0080.00815.66
7.1.190.0070.00815.55
7.1.180.0040.00715.09
7.1.170.0080.00815.24
7.1.160.0070.00415.71
7.1.150.0070.00715.38
7.1.140.0070.00715.54
7.1.130.0060.00915.44
7.1.120.0100.00315.33
7.1.110.0110.00315.59
7.1.100.0060.00616.87
7.1.90.0070.00715.18
7.1.80.0070.00415.52
7.1.70.0030.00716.18
7.1.60.0040.01217.60
7.1.50.0060.01016.28
7.1.40.0030.01015.57
7.1.30.0090.00615.18
7.1.20.0070.00715.23
7.1.10.0030.00815.54
7.1.00.0050.04218.96
7.0.330.0070.00715.10
7.0.320.0100.00615.29
7.0.310.0030.01315.21
7.0.300.0000.01415.13
7.0.290.0000.01015.00
7.0.280.0070.00715.37
7.0.270.0100.00315.38
7.0.260.0030.01015.28
7.0.250.0100.00615.20
7.0.240.0070.00714.96
7.0.230.0070.00714.81
7.0.220.0030.00915.21
7.0.210.0110.00415.12
7.0.200.0030.00915.71
7.0.190.0080.00615.43
7.0.180.0000.01414.91
7.0.170.0080.00615.21
7.0.160.0030.00715.17
7.0.150.0060.00615.32
7.0.140.0070.03818.67
7.0.130.0070.00715.16
7.0.120.0000.01415.43
7.0.110.0050.00315.30
7.0.100.0050.02317.59
7.0.90.0080.02117.44
7.0.80.0070.02317.66
7.0.70.0070.02317.76
7.0.60.0070.01517.59
7.0.50.0070.01917.86
7.0.40.0040.02416.63
7.0.30.0050.03116.75
7.0.20.0080.04316.64
7.0.10.0080.04816.62
7.0.00.0020.03316.71
5.6.400.0040.00813.92
5.6.390.0040.01214.45
5.6.380.0100.00313.86
5.6.370.0040.00713.72
5.6.360.0000.00913.90
5.6.350.0030.00914.21
5.6.340.0100.00714.38
5.6.330.0080.00014.18
5.6.320.0040.00414.21
5.6.310.0030.01014.28
5.6.300.0030.00913.92
5.6.290.0000.01414.27
5.6.280.0040.04117.83
5.6.270.0100.00314.51
5.6.260.0030.01014.14
5.6.250.0080.02217.27
5.6.240.0080.02317.35
5.6.230.0030.02817.28
5.6.220.0050.02317.43
5.6.210.0030.02417.36
5.6.200.0060.02617.69
5.6.190.0030.02217.71
5.6.180.0040.03017.65
5.6.170.0080.03317.50
5.6.160.0080.02217.42
5.6.150.0110.01817.58
5.6.140.0080.04117.85
5.6.130.0050.03517.67
5.6.120.0050.03717.47
5.6.110.0080.04317.45
5.6.100.0030.02817.59
5.6.90.0070.03817.59
5.6.80.0100.02517.12
5.6.70.0100.03517.28
5.6.60.0060.02617.13
5.6.50.0100.03817.21
5.6.40.0070.04317.46
5.6.30.0020.03217.19
5.6.20.0070.03817.16
5.6.10.0030.03117.08
5.6.00.0110.03817.12
5.5.380.0030.02717.45
5.5.370.0030.02317.27
5.5.360.0020.02817.31
5.5.350.0070.02217.24
5.5.340.0060.02417.53
5.5.330.0070.01917.37
5.5.320.0080.04017.42
5.5.310.0030.03517.74
5.5.300.0050.02517.65
5.5.290.0040.04517.60
5.5.280.0070.03917.49
5.5.270.0080.04417.57
5.5.260.0070.04317.54
5.5.250.0030.02717.40
5.5.240.0080.04017.29
5.5.230.0070.02717.24
5.5.220.0050.04417.21
5.5.210.0070.02317.18
5.5.200.0070.04316.94
5.5.190.0050.03017.27
5.5.180.0080.03717.07
5.5.170.0070.00314.29
5.5.160.0100.04417.25
5.5.150.0120.03917.12
5.5.140.0080.04217.12
5.5.130.0080.02816.88
5.5.120.0100.02716.95
5.5.110.0150.03817.34
5.5.100.0050.03817.15
5.5.90.0110.03617.10
5.5.80.0030.04717.25
5.5.70.0060.04217.19
5.5.60.0030.04417.21
5.5.50.0110.02516.92
5.5.40.0150.03817.17
5.5.30.0030.03217.26
5.5.20.0090.03516.92
5.5.10.0080.04517.01
5.5.00.0110.03917.05
5.4.450.0160.03515.07
5.4.440.0060.04015.29
5.4.430.0050.03415.17
5.4.420.0060.02115.32
5.4.410.0000.04915.22
5.4.400.0040.02514.88
5.4.390.0080.04414.93
5.4.380.0070.02814.96
5.4.370.0100.03515.16
5.4.360.0050.02614.98
5.4.350.0090.02914.97
5.4.340.0080.03315.00
5.4.330.0100.00510.98
5.4.320.0060.02614.93
5.4.310.0130.03415.06
5.4.300.0090.04114.95
5.4.290.0070.04114.86
5.4.280.0110.03715.07
5.4.270.0150.02914.82
5.4.260.0070.04015.05
5.4.250.0090.03815.08
5.4.240.0020.04115.09
5.4.230.0070.04015.10
5.4.220.0030.02414.80
5.4.210.0020.02614.93
5.4.200.0070.03414.90
5.4.190.0070.03115.03
5.4.180.0080.03815.10
5.4.170.0080.03714.92
5.4.160.0080.02314.95
5.4.150.0030.03515.06
5.4.140.0030.04213.65
5.4.130.0030.02513.72
5.4.120.0050.03213.55
5.4.110.0070.02213.57
5.4.100.0020.04413.59
5.4.90.0070.02413.67
5.4.80.0080.02513.65
5.4.70.0070.03313.70
5.4.60.0120.03313.71
5.4.50.0070.04213.50
5.4.40.0030.02313.70
5.4.30.0070.02213.46
5.4.20.0020.03713.67
5.4.10.0050.04113.56
5.4.00.0040.02013.38
5.3.290.0050.04312.69
5.3.280.0010.02912.64
5.3.270.0140.02712.46
5.3.260.0070.04512.45
5.3.250.0020.02412.70
5.3.240.0020.02812.55
5.3.230.0050.02312.50
5.3.220.0080.02512.38
5.3.210.0020.04712.35
5.3.200.0080.02512.56
5.3.190.0050.04312.58
5.3.180.0050.03912.60
5.3.170.0070.04312.56
5.3.160.0080.03912.47
5.3.150.0070.03812.51
5.3.140.0050.01812.56
5.3.130.0030.03812.57
5.3.120.0090.03712.62
5.3.110.0000.02912.51
5.3.100.0040.02712.12
5.3.90.0030.02612.29
5.3.80.0070.02312.13
5.3.70.0100.02012.21
5.3.60.0070.03212.33
5.3.50.0070.04012.17
5.3.40.0060.03512.14
5.3.30.0030.03112.21
5.3.20.0020.04612.01
5.3.10.0090.03711.97
5.3.00.0100.03011.88
5.2.170.0030.03712.69
5.2.160.0100.04012.69
5.2.150.0070.05712.69
5.2.140.0070.03312.69
5.2.130.0070.06012.69
5.2.120.0070.05312.69
5.2.110.0000.04712.69
5.2.100.0100.04312.69
5.2.90.0100.05712.69
5.2.80.0170.03712.69
5.2.70.0070.06012.69
5.2.60.0070.06012.69
5.2.50.0030.06712.69
5.2.40.0070.05712.69
5.2.30.0070.03312.69
5.2.20.0070.04712.69
5.2.10.0070.06012.69
5.2.00.0130.04712.69
5.1.60.0030.05312.69
5.1.50.0030.05312.69
5.1.40.0100.03312.69
5.1.30.0070.05312.69
5.1.20.0030.05712.69
5.1.10.0070.05012.69
5.1.00.0030.05312.69
5.0.50.0000.05012.69
5.0.40.0000.04712.69
5.0.30.0000.04012.69
5.0.20.0000.02712.69
5.0.10.0070.03312.69
5.0.00.0070.03012.69
4.4.90.0000.04312.69
4.4.80.0000.02012.69
4.4.70.0000.03312.69
4.4.60.0030.03012.69
4.4.50.0000.03012.69
4.4.40.0030.02712.69
4.4.30.0030.03312.69
4.4.20.0030.03712.69
4.4.10.0000.03012.69
4.4.00.0000.03312.69
4.3.110.0000.02712.69
4.3.100.0070.03012.69
4.3.90.0070.03012.69
4.3.80.0030.03012.69
4.3.70.0000.01712.69
4.3.60.0000.03712.69
4.3.50.0000.02012.69
4.3.40.0000.05712.69
4.3.30.0030.03012.69
4.3.20.0000.03712.69
4.3.10.0030.02712.69
4.3.00.0030.01712.69

preferences:
46.47 ms | 401 KiB | 5 Q