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(){ $arr = $this->curlGet(); return $arr['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.0060.00918.18
8.3.50.0140.00718.20
8.3.40.0120.00318.54
8.3.30.0110.00719.00
8.3.20.0070.00020.29
8.3.10.0040.00421.77
8.3.00.0030.00622.44
8.2.180.0040.01216.50
8.2.170.0120.00322.96
8.2.160.0070.00720.70
8.2.150.0050.00324.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0080.00019.23
8.2.110.0060.00322.21
8.2.100.0090.00317.54
8.2.90.0050.00319.09
8.2.80.0000.00817.97
8.2.70.0060.00317.38
8.2.60.0040.00417.90
8.2.50.0060.00318.07
8.2.40.0080.00018.03
8.2.30.0000.00818.07
8.2.20.0000.00817.58
8.2.10.0040.00417.61
8.2.00.0000.00817.70
8.1.270.0080.00023.91
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0060.00323.94
8.1.230.0000.01119.13
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0060.00317.00
8.1.190.0000.00817.30
8.1.180.0100.00018.10
8.1.170.0050.00518.59
8.1.160.0000.00722.07
8.1.150.0000.00718.51
8.1.140.0050.00317.35
8.1.130.0000.00717.80
8.1.120.0000.00717.43
8.1.110.0070.00017.38
8.1.100.0040.00417.45
8.1.90.0050.00317.25
8.1.80.0000.00817.41
8.1.70.0000.00717.40
8.1.60.0060.00317.42
8.1.50.0040.00417.39
8.1.40.0040.00417.45
8.1.30.0040.00417.62
8.1.20.0030.00617.50
8.1.10.0030.00517.35
8.1.00.0000.00817.44
8.0.300.0070.00018.77
8.0.290.0040.00417.05
8.0.280.0000.00718.44
8.0.270.0040.00417.22
8.0.260.0070.00016.77
8.0.250.0000.00716.84
8.0.240.0040.00316.87
8.0.230.0000.00716.93
8.0.220.0000.00916.87
8.0.210.0000.00716.84
8.0.200.0030.00316.91
8.0.190.0060.00316.86
8.0.180.0040.00416.92
8.0.170.0030.00616.82
8.0.160.0050.00216.72
8.0.150.0000.00716.69
8.0.140.0000.00716.82
8.0.130.0030.00313.32
8.0.120.0070.00315.04
8.0.110.0050.00515.02
8.0.100.0080.00215.04
8.0.90.0040.00715.06
8.0.80.0130.00215.04
8.0.70.0080.00315.02
8.0.60.0060.00415.00
8.0.50.0050.00615.11
8.0.30.0110.00815.73
8.0.20.0090.00616.08
8.0.10.0030.00515.21
8.0.00.0030.01015.53
7.4.330.0050.00015.00
7.4.320.0030.00316.62
7.4.300.0000.00616.59
7.4.290.0040.00416.61
7.4.280.0040.00416.35
7.4.270.0040.00416.46
7.4.260.0030.00616.38
7.4.250.0020.00514.83
7.4.240.0050.00315.40
7.4.230.0040.00514.79
7.4.220.0080.00814.88
7.4.210.0090.00715.68
7.4.200.0070.00314.90
7.4.190.0030.00514.93
7.4.180.0050.00213.32
7.4.160.0070.00013.34
7.4.150.0070.00815.32
7.4.140.0070.00816.30
7.4.130.0080.00715.42
7.4.120.0080.00615.41
7.4.110.0060.00614.74
7.4.100.0090.00614.93
7.4.90.0060.00614.84
7.4.80.0110.00416.24
7.4.70.0080.00414.85
7.4.60.0110.00214.69
7.4.50.0010.00514.69
7.4.40.0070.00517.82
7.4.30.0060.00614.73
7.4.20.0040.00413.02
7.4.10.0050.00313.09
7.4.00.0050.00714.02
7.3.330.0050.00013.10
7.3.320.0030.00313.03
7.3.310.0040.00314.50
7.3.300.0020.00514.62
7.3.290.0060.00614.76
7.3.280.0070.00815.47
7.3.270.0110.00215.22
7.3.260.0080.00414.76
7.3.250.0110.00615.25
7.3.240.0070.00614.71
7.3.230.0050.00814.66
7.3.220.0080.00012.83
7.3.210.0070.00714.74
7.3.200.0100.00316.26
7.3.190.0090.00514.75
7.3.180.0090.00514.59
7.3.170.0080.00314.63
7.3.160.0060.00714.86
7.3.150.0050.00213.19
7.3.140.0040.00413.20
7.3.130.0000.00612.95
7.3.120.0030.00613.86
7.3.110.0060.00013.18
7.3.100.0030.00313.10
7.3.90.0020.00413.24
7.3.80.0050.00213.28
7.3.70.0050.00313.10
7.3.60.0080.00013.44
7.3.50.0040.00413.40
7.3.40.0030.00513.39
7.3.30.0090.00013.34
7.3.20.0030.00514.98
7.3.10.0030.00515.64
7.3.00.0050.00515.84
7.2.340.0000.01213.05
7.2.330.0070.00914.79
7.2.320.0080.00914.80
7.2.310.0110.00514.69
7.2.300.0080.00614.80
7.2.290.0100.00614.85
7.2.280.0120.00313.25
7.2.270.0070.00713.20
7.2.260.0080.00213.23
7.2.250.0130.00013.18
7.2.240.0080.00013.17
7.2.230.0050.00813.23
7.2.220.0110.00413.24
7.2.210.0110.00313.32
7.2.200.0060.00913.20
7.2.190.0120.00013.38
7.2.180.0130.00013.33
7.2.170.0130.00013.36
7.2.160.0070.00713.25
7.2.150.0100.00315.11
7.2.140.0130.00015.16
7.2.130.0070.00515.83
7.2.120.0110.00415.85
7.2.110.0100.00215.80
7.2.100.0060.00716.01
7.2.90.0050.00815.97
7.2.80.0080.00615.98
7.2.70.0110.00215.93
7.2.60.0080.00516.09
7.2.50.0100.00216.00
7.2.40.0080.00515.91
7.2.30.0100.00115.80
7.2.20.0050.00715.87
7.2.10.0070.00715.98
7.2.00.0040.00617.00
7.1.330.0100.00414.08
7.1.320.0110.00014.15
7.1.310.0090.00314.13
7.1.300.0100.00314.16
7.1.290.0040.00814.10
7.1.280.0100.00314.14
7.1.270.0120.00014.19
7.1.260.0100.00314.02
7.1.250.0060.00414.78
7.1.240.0130.00014.14
7.1.230.0100.00314.07
7.1.220.0070.00714.07
7.1.210.0120.00314.02
7.1.200.0110.00114.72
7.1.190.0100.00314.06
7.1.180.0060.00714.10
7.1.170.0110.00214.07
7.1.160.0040.01014.18
7.1.150.0110.00414.11
7.1.140.0070.00714.13
7.1.130.0080.00414.13
7.1.120.0070.00713.95
7.1.110.0090.00314.09
7.1.100.0040.00716.00
7.1.90.0110.00313.94
7.1.80.0000.01214.13
7.1.70.0070.00615.45
7.1.60.0050.00817.02
7.1.50.0100.00915.31
7.1.40.0040.00813.99
7.1.30.0110.00314.16
7.1.20.0130.00014.06
7.1.10.0080.00413.85
7.1.00.0060.03818.32
7.0.330.0100.00313.95
7.0.320.0040.00814.00
7.0.310.0130.00013.95
7.0.300.0120.00013.85
7.0.290.0080.00513.80
7.0.280.0090.00313.98
7.0.270.0090.00313.80
7.0.260.0090.00313.98
7.0.250.0100.00213.97
7.0.240.0090.00314.01
7.0.230.0080.00414.15
7.0.220.0070.00714.05
7.0.210.0120.00013.85
7.0.200.0020.01115.38
7.0.190.0060.00614.03
7.0.180.0110.00314.07
7.0.170.0040.00913.86
7.0.160.0080.00414.00
7.0.150.0120.00014.08
7.0.140.0030.04218.09
7.0.130.0080.00314.07
7.0.120.0080.00414.06
7.0.110.0110.00014.02
7.0.100.0000.01214.09
7.0.90.0060.02216.99
7.0.80.0110.02516.87
7.0.70.0090.02316.95
7.0.60.0080.02017.02
7.0.50.0060.04717.14
7.0.40.0090.03916.95
7.0.30.0080.02217.05
7.0.20.0070.03316.94
7.0.10.0070.04317.05
7.0.00.0100.04317.02
5.6.400.0060.00512.54
5.6.390.0130.00012.40
5.6.380.0060.00612.52
5.6.370.0090.00212.50
5.6.360.0090.00412.51
5.6.350.0000.01212.52
5.6.340.0130.00012.49
5.6.330.0120.00012.65
5.6.320.0080.00412.53
5.6.310.0070.00512.54
5.6.300.0000.01112.43
5.6.290.0040.00812.55
5.6.280.0020.04016.76
5.6.270.0040.00412.55
5.6.260.0000.00512.52
5.6.250.0050.00012.46
5.6.240.0000.02416.59
5.6.230.0150.02216.66
5.6.220.0110.01516.67
5.6.210.0050.02316.63
5.6.200.0050.02216.96
5.6.190.0070.04316.81
5.6.180.0050.03816.88
5.6.170.0000.03516.88
5.6.160.0070.03816.95
5.6.150.0120.04016.95
5.6.140.0090.03616.86
5.6.130.0090.03616.84
5.6.120.0070.04216.71
5.6.110.0130.03516.69
5.6.100.0030.03916.67
5.6.90.0070.04616.81
5.6.80.0060.04316.49
5.6.70.0140.03716.51
5.6.60.0090.03216.51
5.6.50.0130.03816.58
5.6.40.0090.02016.49
5.6.30.0110.03816.61
5.6.20.0110.02716.50
5.6.10.0070.04016.38
5.6.00.0050.04216.33
5.5.380.0070.02316.55
5.5.370.0050.04016.60
5.5.360.0150.01316.41
5.5.350.0080.03216.41
5.5.340.0050.02516.68
5.5.330.0080.03516.65
5.5.320.0030.03616.75
5.5.310.0060.02516.62
5.5.300.0030.02516.57
5.5.290.0060.04516.65
5.5.280.0200.03516.60
5.5.270.0080.03216.44
5.5.260.0130.04216.70
5.5.250.0050.04316.66
5.5.240.0080.03016.52
5.5.230.0080.03916.46
5.5.220.0140.03016.35
5.5.210.0090.04216.53
5.5.200.0030.03716.21
5.5.190.0050.03316.34
5.5.180.0090.04016.30
5.5.170.0120.00012.32
5.5.160.0040.04116.34
5.5.150.0080.04316.12
5.5.140.0110.04016.14
5.5.130.0090.02016.20
5.5.120.0060.04316.18
5.5.110.0060.02816.19
5.5.100.0060.04016.32
5.5.90.0100.03716.26
5.5.80.0090.02016.26
5.5.70.0070.04316.34
5.5.60.0120.03316.19
5.5.50.0080.02516.33
5.5.40.0070.04016.31
5.5.30.0090.04016.39
5.5.20.0090.02516.29
5.5.10.0120.03216.33
5.5.00.0120.02916.38
5.4.450.0080.03515.75
5.4.440.0030.04515.94
5.4.430.0070.03515.98
5.4.420.0050.03115.92
5.4.410.0040.03415.79
5.4.400.0090.02215.88
5.4.390.0090.04415.86
5.4.380.0080.03815.73
5.4.370.0050.04215.87
5.4.360.0040.03615.66
5.4.350.0070.02015.63
5.4.340.0070.04315.67
5.4.330.0080.00412.46
5.4.320.0080.04215.69
5.4.310.0070.02515.75
5.4.300.0050.03015.70
5.4.290.0080.03615.69
5.4.280.0100.03815.76
5.4.270.0080.03015.74
5.4.260.0050.04415.74
5.4.250.0120.03815.59
5.4.240.0140.03015.71
5.4.230.0050.04515.54
5.4.220.0090.04215.70
5.4.210.0090.04015.56
5.4.200.0070.02415.58
5.4.190.0080.04115.70
5.4.180.0080.02515.52
5.4.170.0100.03615.71
5.4.160.0060.04015.57
5.4.150.0060.04115.55
5.4.140.0070.03614.44
5.4.130.0040.02414.35
5.4.120.0050.04014.52
5.4.110.0060.04114.55
5.4.100.0080.03814.47
5.4.90.0060.03214.33
5.4.80.0060.04114.57
5.4.70.0060.04114.51
5.4.60.0040.03914.52
5.4.50.0090.03314.45
5.4.40.0080.03314.52
5.4.30.0110.03114.35
5.4.20.0090.03814.41
5.4.10.0060.03314.37
5.4.00.0020.02414.04
5.3.290.0150.02513.85
5.3.280.0090.03713.69
5.3.270.0070.03913.62
5.3.260.0090.03813.78
5.3.250.0050.02713.71
5.3.240.0100.01813.69
5.3.230.0120.02913.73
5.3.220.0070.02513.63
5.3.210.0030.04613.70
5.3.200.0120.03513.58
5.3.190.0130.03613.62
5.3.180.0080.02713.75
5.3.170.0090.03913.83
5.3.160.0050.04413.79
5.3.150.0080.02613.73
5.3.140.0150.01813.84
5.3.130.0090.03513.68
5.3.120.0070.03013.69
5.3.110.0060.04013.64
5.3.100.0120.03713.43
5.3.90.0080.02413.43
5.3.80.0110.02013.46
5.3.70.0110.02813.50
5.3.60.0090.03513.46
5.3.50.0070.02413.47
5.3.40.0090.02013.28
5.3.30.0050.02513.37
5.3.20.0040.02213.11
5.3.10.0070.03813.12
5.3.00.0030.03613.23

preferences:
63.2 ms | 400 KiB | 5 Q