3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AmoApi { private $params = array('USER_LOGIN' =>'', 'USER_HASH' => ''); private $link = ''; const MAIN_LINK = ''; private $post_params; /** * @param mixed $post_params */ public function setPostParams($post_params) { if($post_params['placement'] == 1) { $post_params['placement'] = '2040058';//Да }elseif($post_params['placement'] == 0){ $post_params['placement'] = '2040060';//Нет } $this->post_params = $post_params; } public function __construct(){ $this->auth(); } /** * @param mixed $link */ public function setLink($link) { $this->link = $link; } public function getCurrentUserInfo(){ return $this->curlGet()['response']['account']; } protected function auth() { return $this->curlPost($this->params, self::MAIN_LINK.$this->link); } protected function curlPost($params, $link) { $curl=curl_init(); #Сохраняем дескриптор сеанса cURL #Устанавливаем необходимые опции для сеанса cURL curl_setopt($curl,CURLOPT_RETURNTRANSFER,true); curl_setopt($curl,CURLOPT_USERAGENT,'amoCRM-API-client/1.0'); curl_setopt($curl,CURLOPT_URL,$link); curl_setopt($curl,CURLOPT_CUSTOMREQUEST,'POST'); curl_setopt($curl,CURLOPT_POSTFIELDS,json_encode($params)); curl_setopt($curl,CURLOPT_HTTPHEADER,array('Content-Type: application/json')); curl_setopt($curl,CURLOPT_HEADER,false); curl_setopt($curl,CURLOPT_COOKIEFILE,dirname(__FILE__).'/cookie.txt'); #PHP>5.3.6 dirname(__FILE__) -> __DIR__ curl_setopt($curl,CURLOPT_COOKIEJAR,dirname(__FILE__).'/cookie.txt'); #PHP>5.3.6 dirname(__FILE__) -> __DIR__ curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0); curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0); $out=curl_exec($curl); #Инициируем запрос к API и сохраняем ответ в переменную $code=curl_getinfo($curl,CURLINFO_HTTP_CODE); #Получим HTTP-код ответа сервера curl_close($curl); #Заверашем сеанс cURL return json_decode($out, true); } protected function curlGet($link = '') { $curl=curl_init(); #Сохраняем дескриптор сеанса cURL #Устанавливаем необходимые опции для сеанса cURL curl_setopt($curl,CURLOPT_RETURNTRANSFER,true); curl_setopt($curl,CURLOPT_USERAGENT,'amoCRM-API-client/1.0'); curl_setopt($curl,CURLOPT_URL,$link); curl_setopt($curl,CURLOPT_HEADER,false); curl_setopt($curl,CURLOPT_COOKIEFILE,dirname(__FILE__).'/cookie.txt'); #PHP>5.3.6 dirname(__FILE__) -> __DIR__ curl_setopt($curl,CURLOPT_COOKIEJAR,dirname(__FILE__).'/cookie.txt'); #PHP>5.3.6 dirname(__FILE__) -> __DIR__ curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0); curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0); $out=curl_exec($curl); #Инициируем запрос к API и сохраняем ответ в переменную $code=curl_getinfo($curl,CURLINFO_HTTP_CODE); curl_close($curl); /** * Данные получаем в формате JSON, поэтому, для получения читаемых данных, * нам придётся перевести ответ в формат, понятный PHP */ $Response=json_decode($out,true); return $Response; } protected function addLeads() { $link = self::MAIN_LINK.'private/api/v2/json/leads/set'; $current_user = $this->getCurrentUserInfo(); $params['request']['leads']['add']= array( array( 'name'=>'Заявка с сайта № ' .$this->getNumRequest(), 'status_id'=>7540914, //Необработанная заявка // 'price'=>5000, 'responsible_user_id'=>209582, 'custom_fields'=>array( //Источник заявки array( 'id' => 905986, 'values' =>array( array('value'=>"2050856")//2050856 => string 'Сайт' ) ), //Трудоустроен array( 'id' => 901454, 'values' =>array( array('value'=>$this->post_params['placement']) ) ), //Сумма кредита array( 'id' => 896588, 'values' => array(array('value'=>$this->post_params['summa'])) ) ) ) ); return $this->curlPost($params, $link)['response']['leads']['add']; } protected function addContacts($lead_id = 0) { $link = self::MAIN_LINK . 'private/api/v2/json/contacts/set'; $params['request']['contacts']['add'] = array( array( 'name' => $this->post_params['name'],//$contact['name'], 'linked_leads_id' => array( $lead_id ), 'custom_fields' => array( array( //Телефоны 'id' => 861010, //Уникальный индентификатор заполняемого дополнительного поля 'values' => array( array( 'value' => $this->post_params['phone'],//$contact_phone, 'enum' => 'WORK' //Мобильный ) ) ), array( //E-mails 'id' => 861012, 'values' => array( array( 'value' => $this->post_params['email'],//$contact_email, 'enum' => 'WORK', //Рабочий ) ) ), array( //Город проживания 'id' => 901490, 'values' => array( array( 'value' => $this->post_params['region'] ) ) ), //Полных лет array( 'id' => 896596, 'values' => array(array('value'=>$this->post_params['age'])) ) ) ) ); return $this->curlPost($params, $link); } public function addConnectedRow() { $lead_id = $this->addLeads()[0]['id']; $this->error[] = $lead_id; $contact = $this->addContacts($lead_id); $this->error[] = $contact; return $contact; } protected function getNumRequest(){ $file = 'request_num'; if(file_exists($file)){ $id = (int)file_get_contents($file) + 1; file_put_contents($file, $id); return $id; } file_put_contents($file, 1); return 1; } }

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.00718.30
8.3.50.0180.00621.93
8.3.40.0120.00918.69
8.3.30.0060.01019.09
8.3.20.0070.00020.21
8.3.10.0080.00021.92
8.3.00.0000.00822.45
8.2.180.0070.01416.38
8.2.170.0070.00722.96
8.2.160.0120.00320.77
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0030.00519.23
8.2.110.0090.00022.25
8.2.100.0040.00817.52
8.2.90.0060.00319.17
8.2.80.0030.00617.97
8.2.70.0040.00417.50
8.2.60.0040.00417.80
8.2.50.0120.00018.07
8.2.40.0030.00618.03
8.2.30.0000.00717.96
8.2.20.0050.00217.73
8.2.10.0040.00417.61
8.2.00.0090.00017.74
8.1.280.0070.01025.92
8.1.270.0040.00423.84
8.1.260.0080.00026.35
8.1.250.0040.01828.09
8.1.240.0030.00623.91
8.1.230.0080.00318.96
8.1.220.0060.00317.74
8.1.210.0050.00318.77
8.1.200.0050.00517.35
8.1.190.0000.00817.41
8.1.180.0040.00418.10
8.1.170.0050.00318.51
8.1.160.0000.00722.02
8.1.150.0040.00418.59
8.1.140.0030.00517.42
8.1.130.0030.00317.87
8.1.120.0040.00417.32
8.1.110.0030.00517.38
8.1.100.0040.00417.38
8.1.90.0030.00617.31
8.1.80.0000.00717.30
8.1.70.0030.00317.27
8.1.60.0000.00817.48
8.1.50.0050.00317.39
8.1.40.0040.00417.43
8.1.30.0030.00517.61
8.1.20.0040.00417.49
8.1.10.0040.00417.40
8.1.00.0040.00417.31
8.0.300.0060.00318.77
8.0.290.0050.00317.18
8.0.280.0040.00418.39
8.0.270.0040.00417.13
8.0.260.0030.00316.71
8.0.250.0030.00316.91
8.0.240.0040.00316.79
8.0.230.0070.00016.95
8.0.220.0000.00716.71
8.0.210.0030.00316.73
8.0.200.0000.00616.79
8.0.190.0000.00916.88
8.0.180.0000.00816.89
8.0.170.0080.00016.84
8.0.160.0000.00816.85
8.0.150.0040.00416.80
8.0.140.0000.00716.84
8.0.130.0030.00313.25
8.0.120.0070.00415.01
8.0.110.0070.00415.08
8.0.100.0090.00114.99
8.0.90.0070.00415.03
8.0.80.0050.01015.05
8.0.70.0070.00415.11
8.0.60.0030.00514.92
8.0.50.0030.00515.02
8.0.30.0110.00815.66
8.0.20.0090.00916.04
8.0.10.0010.00615.15
8.0.00.0050.01015.68
7.4.330.0000.00515.00
7.4.320.0030.00316.46
7.4.300.0000.00616.48
7.4.290.0080.00016.37
7.4.280.0030.00616.42
7.4.270.0030.00316.56
7.4.260.0000.00716.50
7.4.250.0040.00414.87
7.4.240.0050.00415.41
7.4.230.0040.00614.96
7.4.220.0110.00514.85
7.4.210.0100.00315.70
7.4.200.0030.00614.92
7.4.190.0040.00414.78
7.4.180.0070.00213.25
7.4.160.0110.00314.97
7.4.150.0070.00715.35
7.4.140.0090.00716.27
7.4.130.0050.00915.29
7.4.120.0050.01015.32
7.4.110.0110.00314.79
7.4.100.0090.00514.80
7.4.90.0090.00514.89
7.4.80.0040.01016.26
7.4.70.0050.00714.77
7.4.60.0100.00314.76
7.4.50.0040.00314.85
7.4.40.0060.00517.74
7.4.30.0050.00714.67
7.4.20.0000.00813.02
7.4.10.0030.00513.07
7.4.00.0020.00914.15
7.3.330.0000.00613.25
7.3.320.0030.00313.29
7.3.310.0050.00214.56
7.3.300.0040.00314.65
7.3.290.0050.00614.73
7.3.280.0050.00915.50
7.3.270.0120.00415.29
7.3.260.0060.00714.91
7.3.250.0060.00915.29
7.3.240.0060.00714.63
7.3.230.0040.00814.64
7.3.220.0030.00512.95
7.3.210.0060.01014.82
7.3.200.0080.00716.29
7.3.190.0100.00414.67
7.3.180.0060.00614.70
7.3.170.0060.00514.71
7.3.160.0060.00714.79
7.3.150.0020.00412.96
7.3.140.0020.00413.15
7.3.130.0050.00013.11
7.3.120.0040.00613.87
7.3.110.0020.00413.09
7.3.100.0030.00312.97
7.3.90.0040.00413.44
7.3.80.0020.00413.05
7.3.70.0030.00313.30
7.3.60.0060.00013.16
7.3.50.0060.00013.42
7.3.40.0000.00613.39
7.3.30.0000.00813.24
7.3.20.0060.00315.12
7.3.10.0090.00615.67
7.3.00.0140.00515.63
7.2.340.0130.00013.11
7.2.330.0120.00314.77
7.2.320.0070.01114.86
7.2.310.0130.00614.83
7.2.300.0070.01214.76
7.2.290.0040.01114.81
7.2.280.0050.00913.31
7.2.270.0110.00313.01
7.2.260.0080.00313.04
7.2.250.0030.01013.21
7.2.240.0030.00313.09
7.2.230.0120.00013.24
7.2.220.0130.00013.31
7.2.210.0090.00413.10
7.2.200.0140.00013.15
7.2.190.0070.00713.35
7.2.180.0080.00513.39
7.2.170.0130.00013.21
7.2.160.0110.00313.45
7.2.150.0060.00614.81
7.2.140.0040.00915.10
7.2.130.0130.00615.83
7.2.120.0160.00215.52
7.2.110.0020.01015.73
7.2.100.0080.00715.51
7.2.90.0190.00415.93
7.2.80.0140.00315.85
7.2.70.0070.00915.59
7.2.60.0110.00616.22
7.2.50.0120.00215.71
7.2.40.0110.01115.73
7.2.30.0110.00715.61
7.2.20.0120.00816.07
7.2.10.0170.00315.77
7.2.00.0100.00415.79
7.1.330.0000.01214.16
7.1.320.0120.00214.00
7.1.310.0100.00314.18
7.1.300.0090.00313.98
7.1.290.0040.00814.16
7.1.280.0100.00314.02
7.1.270.0100.00214.20
7.1.260.0080.00414.23
7.1.250.0130.00514.83
7.1.240.0120.00014.06
7.1.230.0100.00314.07
7.1.220.0110.00214.07
7.1.210.0060.00614.18
7.1.200.0110.00214.94
7.1.190.0110.00313.99
7.1.180.0080.00413.93
7.1.170.0070.00514.11
7.1.160.0040.00814.11
7.1.150.0030.00914.15
7.1.140.0060.00614.04
7.1.130.0060.00614.04
7.1.120.0100.00314.12
7.1.110.0050.00714.09
7.1.100.0130.00014.07
7.1.90.0100.00314.05
7.1.80.0040.00814.20
7.1.70.0040.00615.47
7.1.60.0060.00615.63
7.1.50.0080.00515.35
7.1.40.0070.00713.98
7.1.30.0080.00414.17
7.1.20.0120.00014.07
7.1.10.0080.00414.11
7.1.00.0070.03918.28
7.0.330.0040.00814.01
7.0.320.0070.00713.96
7.0.310.0070.00513.77
7.0.300.0090.00414.02
7.0.290.0100.00213.99
7.0.280.0130.00013.98
7.0.270.0130.00013.76
7.0.260.0090.00413.95
7.0.250.0070.00714.20
7.0.240.0110.00213.97
7.0.230.0060.00614.04
7.0.220.0130.00013.89
7.0.210.0120.00014.06
7.0.200.0030.01115.40
7.0.190.0070.00514.07
7.0.180.0090.00414.14
7.0.170.0130.00014.14
7.0.160.0080.00513.79
7.0.150.0120.00013.83
7.0.140.0060.03818.03
7.0.130.0060.00614.25
7.0.120.0080.00313.95
7.0.110.0040.00813.82
7.0.100.0120.00013.88
7.0.90.0390.04216.98
7.0.80.0340.03916.93
7.0.70.0340.04416.86
7.0.60.0340.04117.02
7.0.50.0260.03017.19
7.0.40.0080.04017.13
7.0.30.0060.03816.98
7.0.20.0080.02817.01
7.0.10.0150.03517.11
7.0.00.0070.04417.07
5.6.400.0110.00012.61
5.6.390.0060.00612.66
5.6.380.0060.00612.57
5.6.370.0080.00412.51
5.6.360.0000.01112.55
5.6.350.0060.00612.68
5.6.340.0130.00012.68
5.6.330.0000.01212.68
5.6.320.0100.00212.50
5.6.310.0060.00712.42
5.6.300.0060.00612.56
5.6.290.0040.00812.61
5.6.280.0020.04016.62
5.6.270.0060.00012.69
5.6.260.0000.00512.70
5.6.250.0000.00612.63
5.6.240.0080.02616.45
5.6.230.0040.05116.57
5.6.220.0100.04016.65
5.6.210.0110.04116.68
5.6.200.0050.02816.82
5.6.190.0080.02316.87
5.6.180.0050.04616.87
5.6.170.0080.02516.88
5.6.160.0100.04116.80
5.6.150.0070.02816.99
5.6.140.0100.02316.82
5.6.130.0110.03816.76
5.6.120.0120.03716.79
5.6.110.0090.04216.70
5.6.100.0140.03916.83
5.6.90.0150.01816.83
5.6.80.0080.04016.57
5.6.70.0090.04016.54
5.6.60.0040.04316.48
5.6.50.0110.03816.42
5.6.40.0110.02516.39
5.6.30.0100.04016.54
5.6.20.0080.04016.44
5.6.10.0120.02216.50
5.6.00.0140.03316.51
5.5.380.0160.03016.47
5.5.370.0060.02816.58
5.5.360.0110.03916.32
5.5.350.0100.02816.39
5.5.340.0120.03716.55
5.5.330.0120.03316.77
5.5.320.0100.03816.71
5.5.310.0110.03616.68
5.5.300.0070.03016.49
5.5.290.0100.02616.71
5.5.280.0030.02716.68
5.5.270.0080.04216.57
5.5.260.0110.03716.69
5.5.250.0090.04016.61
5.5.240.0080.04116.41
5.5.230.0080.04016.29
5.5.220.0110.03816.23
5.5.210.0080.03616.40
5.5.200.0040.04516.21
5.5.190.0080.02816.30
5.5.180.0050.02716.31
5.5.170.0040.00812.32
5.5.160.0090.04216.18
5.5.150.0090.04016.17
5.5.140.0070.03616.27
5.5.130.0070.02716.19
5.5.120.0070.02916.23
5.5.110.0030.04016.11
5.5.100.0040.04616.17
5.5.90.0080.03116.18
5.5.80.0070.04016.27
5.5.70.0110.03616.34
5.5.60.0050.04516.35
5.5.50.0080.03316.30
5.5.40.0080.03816.21
5.5.30.0130.03716.37
5.5.20.0090.03116.26
5.5.10.0100.03716.24
5.5.00.0100.03516.30
5.4.450.0040.02916.01
5.4.440.0070.04315.97
5.4.430.0090.03916.04
5.4.420.0120.03515.82
5.4.410.0090.02015.78
5.4.400.0140.03415.74
5.4.390.0070.03815.80
5.4.380.0070.04115.58
5.4.370.0080.03815.72
5.4.360.0080.04015.74
5.4.350.0060.02115.78
5.4.340.0030.04615.67
5.4.330.0070.00512.58
5.4.320.0070.04015.64
5.4.310.0060.03915.84
5.4.300.0050.04315.88
5.4.290.0090.04015.80
5.4.280.0100.02715.89
5.4.270.0050.04315.75
5.4.260.0090.03615.80
5.4.250.0110.02715.83
5.4.240.0100.02715.86
5.4.230.0030.04315.60
5.4.220.0070.02715.64
5.4.210.0090.03515.61
5.4.200.0080.04215.63
5.4.190.0100.04015.72
5.4.180.0080.04015.66
5.4.170.0100.02315.73
5.4.160.0020.03215.65
5.4.150.0060.04115.68
5.4.140.0040.02814.43
5.4.130.0100.03214.36
5.4.120.0080.02014.47
5.4.110.0060.03514.44
5.4.100.0080.02314.35
5.4.90.0080.03314.56
5.4.80.0090.01814.48
5.4.70.0040.02214.55
5.4.60.0070.02214.46
5.4.50.0040.02114.43
5.4.40.0060.01814.44
5.4.30.0070.02214.35
5.4.20.0050.01914.35
5.4.10.0060.01914.50
5.4.00.0030.02114.12
5.3.290.0060.04213.69
5.3.280.0110.03813.73
5.3.270.0090.02513.73
5.3.260.0040.03913.78
5.3.250.0030.02713.60
5.3.240.0090.02013.55
5.3.230.0030.04113.70
5.3.220.0080.03613.70
5.3.210.0190.01913.63
5.3.200.0090.03113.68
5.3.190.0060.02313.61
5.3.180.0020.02413.64
5.3.170.0120.02313.77
5.3.160.0060.02013.77
5.3.150.0040.02913.66
5.3.140.0090.01713.69
5.3.130.0080.02313.66
5.3.120.0000.02513.71
5.3.110.0050.02113.64
5.3.100.0100.01713.43
5.3.90.0040.02313.54
5.3.80.0040.02213.27
5.3.70.0080.01813.30
5.3.60.0070.01813.31
5.3.50.0030.02213.38
5.3.40.0060.01813.21
5.3.30.0060.03713.44
5.3.20.0060.03113.10
5.3.10.0040.02213.14
5.3.00.0040.01913.17

preferences:
61.07 ms | 400 KiB | 5 Q