3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Super-simple, minimum abstraction MailChimp API v3 wrapper * * Uses curl if available, falls back to file_get_contents and HTTP stream. * This probably has more comments than code. * * @author Drew McLellan <drew.mclellan@gmail.com> * @version 2.0 */ class MailChimp { private $api_key; private $api_endpoint = 'https://<dc>.api.mailchimp.com/3.0'; private $verify_ssl = true; /** * Create a new instance * @param string $api_key Your MailChimp API key */ public function __construct($api_key) { $this->api_key = $api_key; list(, $datacentre) = explode('-', $this->api_key); $this->api_endpoint = str_replace('<dc>', $datacentre, $this->api_endpoint); } public function delete($method, $args=array(), $timeout=10) { return $this->makeRequest('delete', $method, $args, $timeout); } public function get($method, $args=array(), $timeout=10) { return $this->makeRequest('get', $method, $args, $timeout); } public function patch($method, $args=array(), $timeout=10) { return $this->makeRequest('patch', $method, $args, $timeout); } public function post($method, $args=array(), $timeout=10) { return $this->makeRequest('post', $method, $args, $timeout); } public function put($method, $args=array(), $timeout=10) { return $this->makeRequest('put', $method, $args, $timeout); } /** * Performs the underlying HTTP request. Not very exciting * @param string $$http_verb The HTTP verb to use: get, post, put, patch, delete * @param string $method The API method to be called * @param array $args Assoc array of parameters to be passed * @return array Assoc array of decoded result */ private function makeRequest($http_verb, $method, $args=array(), $timeout=10) { $args['apikey'] = $this->api_key; $url = $this->api_endpoint.'/'.$method; $json_data = json_encode((object)$args); if (function_exists('curl_init') && function_exists('curl_setopt')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, 'drewm:'.$this->api_key); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/vnd.api+json', 'Content-Type: application/vnd.api+json')); curl_setopt($ch, CURLOPT_USERAGENT, 'DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); switch($http_verb) { case 'post': curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); break; case 'get': $query = http_build_query($args); curl_setopt($ch, CURLOPT_URL, $url.'?'.$query); break; case 'delete': curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); break; case 'patch': curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); break; } $result = curl_exec($ch); curl_close($ch); } else { throw new Exception("cURL support is required, but can't be found."); } return $result ? json_decode($result, true) : false; } } // MailChimp Configuration $api_key = "f36426878616bc7a2e1fc918ab9f9de5-us12"; // ENTER YOUR API KEY HERE $list_id = "d7973804f4"; // ENTER YOUR LIST ID HERE $MailChimp = new MailChimp($api_key); $result = $MailChimp->post('lists/' .$list_id. '/members', array( 'email_address' => 'something@gmail.com', 'status' => 'subscribed' )); if($result['status'] == 'subscribed') { echo json_encode(array('error' => false, 'message' => 'Thanks for subscribing with us')); exit; } else { echo json_encode(array('error' => true, 'message' => $result['title'])); exit; }

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.01116.88
8.3.50.0150.00521.99
8.3.40.0120.00318.96
8.3.30.0070.00718.92
8.3.20.0070.00020.39
8.3.10.0030.00523.54
8.3.00.0030.00519.50
8.2.180.0070.01116.63
8.2.170.0100.00722.96
8.2.160.0110.01120.66
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0050.00326.16
8.2.120.0030.00918.00
8.2.110.0050.00522.16
8.2.100.0060.00618.03
8.2.90.0000.00818.16
8.2.80.0000.00821.09
8.2.70.0000.00817.75
8.2.60.0040.00417.75
8.2.50.0080.00018.07
8.2.40.0000.00819.55
8.2.30.0040.00420.83
8.2.20.0030.00517.92
8.2.10.0090.00018.13
8.2.00.0030.00618.28
8.1.280.0090.01225.92
8.1.270.0060.00323.91
8.1.260.0050.00326.35
8.1.250.0000.00728.09
8.1.240.0050.00522.50
8.1.230.0130.00320.96
8.1.220.0040.00417.89
8.1.210.0030.00618.84
8.1.200.0100.00217.35
8.1.190.0070.00317.35
8.1.180.0050.00318.10
8.1.170.0000.00818.77
8.1.160.0000.00722.11
8.1.150.0000.00718.96
8.1.140.0030.00519.58
8.1.130.0000.00717.71
8.1.120.0040.00417.47
8.1.110.0080.00017.46
8.1.100.0040.00417.46
8.1.90.0080.00017.49
8.1.80.0030.00517.48
8.1.70.0000.00717.51
8.1.60.0030.00617.68
8.1.50.0090.00317.63
8.1.40.0100.00317.65
8.1.30.0030.00617.64
8.1.20.0040.00417.58
8.1.10.0000.00817.55
8.1.00.0000.00817.62
8.0.300.0030.00520.01
8.0.290.0040.00416.88
8.0.280.0040.00418.48
8.0.270.0040.00417.36
8.0.260.0000.00717.36
8.0.250.0000.00817.12
8.0.240.0040.00417.12
8.0.230.0040.00417.05
8.0.220.0000.00716.93
8.0.210.0090.00017.04
8.0.200.0080.00017.11
8.0.190.0080.00017.07
8.0.180.0030.00517.07
8.0.170.0000.00817.07
8.0.160.0000.00917.08
8.0.150.0000.00716.97
8.0.140.0000.00817.06
8.0.130.0060.00013.55
8.0.120.0040.00417.01
8.0.110.0040.00417.08
8.0.100.0040.00416.96
8.0.90.0040.00417.11
8.0.80.0000.01517.11
8.0.70.0040.00417.10
8.0.60.0050.00317.07
8.0.50.0080.00016.96
8.0.30.0090.00917.24
8.0.20.0140.00917.42
8.0.10.0050.00317.29
8.0.00.0060.01016.73
7.4.330.0050.00015.08
7.4.320.0000.00716.59
7.4.300.0030.00316.74
7.4.290.0000.00716.62
7.4.280.0000.00716.61
7.4.270.0000.00816.68
7.4.260.0030.00316.64
7.4.250.0030.00516.58
7.4.240.0050.00216.56
7.4.230.0070.00016.77
7.4.220.0120.01216.78
7.4.210.0170.00416.79
7.4.200.0000.00716.51
7.4.160.0030.01316.68
7.4.150.0070.01617.40
7.4.140.0140.00617.86
7.4.130.0050.01116.75
7.4.120.0130.00516.66
7.4.110.0040.01416.45
7.4.100.0160.00316.47
7.4.90.0110.00716.74
7.4.80.0080.00919.39
7.4.70.0070.01016.70
7.4.60.0130.00616.65
7.4.50.0030.00316.64
7.4.40.0060.00916.50
7.4.30.0130.01016.81
7.4.00.0090.00715.10
7.3.330.0070.00013.52
7.3.320.0030.00313.54
7.3.310.0080.00016.42
7.3.300.0000.00716.43
7.3.290.0070.00916.48
7.3.280.0120.00716.49
7.3.270.0070.01117.40
7.3.260.0120.00616.54
7.3.250.0110.00716.59
7.3.240.0090.01016.49
7.3.230.0120.00616.61
7.3.210.0130.00316.46
7.3.200.0150.00916.54
7.3.190.0090.00616.76
7.3.180.0100.00716.69
7.3.170.0060.01016.65
7.3.160.0080.00816.50
7.3.120.0030.01515.13
7.3.110.0070.00715.02
7.3.100.0070.00514.78
7.3.90.0050.00914.94
7.3.80.0060.00815.02
7.3.70.0040.00815.03
7.3.60.0060.00814.85
7.3.50.0060.00814.89
7.3.40.0090.00714.91
7.3.30.0070.00514.68
7.3.20.0030.01016.69
7.3.10.0050.00616.72
7.3.00.0070.00516.68
7.2.330.0140.00616.57
7.2.320.0100.01316.95
7.2.310.0040.01316.88
7.2.300.0060.01616.87
7.2.290.0110.00716.95
7.2.250.0120.00615.12
7.2.240.0040.00815.21
7.2.230.0030.01015.13
7.2.220.0040.00915.17
7.2.210.0080.00815.21
7.2.200.0090.00515.11
7.2.190.0070.00915.25
7.2.180.0060.00915.16
7.2.170.0050.01215.05
7.2.160.0120.00615.24
7.2.150.0040.01216.97
7.2.140.0130.00716.69
7.2.130.0070.01116.84
7.2.120.0030.01316.94
7.2.110.0080.00616.99
7.2.100.0030.00717.14
7.2.90.0100.00316.89
7.2.80.0040.01117.04
7.2.70.0030.00616.97
7.2.60.0260.00816.85
7.2.50.0090.00616.99
7.2.40.0070.00717.03
7.2.30.0060.00717.07
7.2.20.0090.00616.72
7.2.10.0060.01216.83
7.2.00.0070.00618.12
7.1.330.0020.01215.84
7.1.320.0050.00615.91
7.1.310.0050.01115.77
7.1.300.0030.01015.81
7.1.290.0060.00715.79
7.1.280.0070.00715.98
7.1.270.0050.00915.83
7.1.260.0030.00715.80
7.1.250.0000.01115.86
7.1.200.0060.01015.87
7.1.100.0100.01318.04
7.1.70.0040.00417.25
7.1.60.0130.01019.43
7.1.50.0040.01817.05
7.1.00.0070.07322.33
7.0.200.0210.00715.04
7.0.90.0370.08720.13
7.0.80.0430.07020.04
7.0.70.0170.06320.03
7.0.60.0570.05720.03
7.0.50.0570.08020.48
7.0.40.0100.08020.19
7.0.30.0100.04720.03
7.0.20.0170.07720.19
7.0.10.0030.08320.13
7.0.00.0070.06720.04
5.6.280.0000.04321.14
5.6.240.0030.05720.72
5.6.230.0030.04720.58
5.6.220.0100.08020.74
5.6.210.0100.07720.70
5.6.200.0070.07321.00
5.6.190.0130.07320.95
5.6.180.0100.04721.04
5.6.170.0100.07721.05
5.6.160.0070.08021.12
5.6.150.0100.07321.05
5.6.140.0030.08021.08
5.6.130.0030.08320.97
5.6.120.0070.09021.09
5.6.110.0030.06321.05
5.6.100.0000.06320.96
5.6.90.0200.05321.05
5.6.80.0000.08320.49
5.6.70.0030.05720.35
5.6.60.0100.07320.45
5.6.50.0070.07720.59
5.6.40.0030.08320.40
5.6.30.0170.06020.47
5.6.20.0200.07320.44
5.6.10.0000.07320.47
5.6.00.0000.08020.43
5.5.380.0100.08020.40
5.5.370.0170.07020.55
5.5.360.0030.08720.54
5.5.350.0070.06320.50
5.5.340.0230.06720.91
5.5.330.0100.04320.82
5.5.320.0000.05320.91
5.5.310.0070.04720.80
5.5.300.0030.07720.68
5.5.290.0070.07720.91
5.5.280.0070.08720.88
5.5.270.0000.06020.92
5.5.260.0000.08320.92
5.5.250.0100.08020.47
5.5.240.0070.05320.32
5.5.230.0070.05020.30
5.5.220.0000.07720.18
5.5.210.0030.05020.15
5.5.200.0030.08320.26
5.5.190.0100.07720.20
5.5.180.0130.07320.13
5.5.160.0100.07320.20
5.5.150.0070.07720.27
5.5.140.0000.04720.11
5.5.130.0130.07320.21
5.5.120.0070.08020.12
5.5.110.0070.08020.02
5.5.100.0070.05320.20
5.5.90.0100.08020.14
5.5.80.0070.05320.02
5.5.70.0100.07020.10
5.5.60.0030.04719.97
5.5.50.0130.07720.00
5.5.40.0070.05020.19
5.5.30.0070.07020.17
5.5.20.0170.07020.17
5.5.10.0100.08020.01
5.5.00.0100.05320.01
5.4.450.0030.05319.38
5.4.440.0030.05719.36
5.4.430.0030.06019.45
5.4.420.0030.06719.36
5.4.410.0170.06719.32
5.4.400.0030.08318.95
5.4.390.0030.05719.05
5.4.380.0100.07319.13
5.4.370.0100.06019.18
5.4.360.0030.05319.21
5.4.350.0130.05019.05
5.4.340.0100.06719.05
5.4.320.0130.06318.86
5.4.310.0100.04019.04
5.4.300.0100.07719.04
5.4.290.0000.08319.13
5.4.280.0070.04318.98
5.4.270.0000.04719.02
5.4.260.0030.05719.02
5.4.250.0030.04719.15
5.4.240.0070.05319.22
5.4.230.0100.04019.20
5.4.220.0100.07719.12
5.4.210.0030.07719.02
5.4.200.0100.03719.17
5.4.190.0000.05019.08
5.4.180.0030.07718.93
5.4.170.0000.08318.86
5.4.160.0100.06719.22
5.4.150.0100.07019.08
5.4.140.0070.07316.34
5.4.130.0030.08016.46
5.4.120.0100.06716.47
5.4.110.0030.07316.35
5.4.100.0070.05316.47
5.4.90.0030.07716.49
5.4.80.0100.05716.44
5.4.70.0030.05016.51
5.4.60.0100.05716.33
5.4.50.0100.03716.43
5.4.40.0030.07016.41
5.4.30.0130.06316.36
5.4.20.0030.07316.47
5.4.10.0030.07716.44
5.4.00.0070.07315.84
5.3.290.0070.04714.85
5.3.280.0100.07314.57
5.3.270.0100.07314.57
5.3.260.0070.04714.63
5.3.250.0030.07314.58
5.3.240.0070.07314.60
5.3.230.0070.07314.62
5.3.220.0030.04014.63
5.3.210.0030.03714.59
5.3.200.0100.07714.57
5.3.190.0030.07714.68
5.3.180.0030.04714.58
5.3.170.0100.05714.59
5.3.160.0070.07714.56
5.3.150.0070.07314.70
5.3.140.0030.04714.53
5.3.130.0200.06314.70
5.3.120.0100.07714.64
5.3.110.0070.06314.56
5.3.100.0070.07314.10
5.3.90.0030.06314.01
5.3.80.0030.07714.18
5.3.70.0070.07714.07
5.3.60.0070.07313.97
5.3.50.0100.03713.91
5.3.40.0070.05714.13
5.3.30.0030.05713.88
5.3.20.0000.03713.80
5.3.10.0030.05713.79
5.3.00.0070.06313.79
5.2.170.0100.07011.10
5.2.160.0070.05011.20
5.2.150.0030.06711.27
5.2.140.0030.06311.09
5.2.130.0000.05011.17
5.2.120.0000.03311.07
5.2.110.0030.04011.24
5.2.100.0100.05311.24
5.2.90.0070.06311.22
5.2.80.0030.05011.15
5.2.70.0000.06311.20
5.2.60.0170.05711.00
5.2.50.0030.06711.17
5.2.40.0070.06310.86
5.2.30.0030.04011.12
5.2.20.0030.03710.92
5.2.10.0030.06010.97
5.2.00.0100.03010.76
5.1.60.0000.05710.15
5.1.50.0000.05710.14
5.1.40.0000.06310.05
5.1.30.0030.05310.49
5.1.20.0070.05310.52
5.1.10.0130.04010.17
5.1.00.0000.04710.19
5.0.50.0070.0308.69
5.0.40.0100.0308.54
5.0.30.0070.0608.35
5.0.20.0030.0438.32
5.0.10.0030.0408.09
5.0.00.0000.0678.22
4.4.90.0000.0207.06
4.4.80.0030.0307.06
4.4.70.0000.0277.06
4.4.60.0030.0337.06
4.4.50.0030.0337.06
4.4.40.0030.0377.06
4.4.30.0000.0207.06
4.4.20.0000.0307.06
4.4.10.0070.0177.06
4.4.00.0070.0507.06
4.3.110.0000.0377.06
4.3.100.0030.0337.06
4.3.90.0030.0337.06
4.3.80.0070.0307.06
4.3.70.0030.0337.06
4.3.60.0000.0337.06
4.3.50.0000.0377.06
4.3.40.0030.0277.06
4.3.30.0070.0237.06
4.3.20.0030.0377.06
4.3.10.0000.0377.06
4.3.00.0030.0237.06

preferences:
62.22 ms | 401 KiB | 5 Q