3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AmoApi { private $params = array(); private $link = 'private/api/auth.php?type=json'; const MAIN_LINK = 'https://creditodobren.amocrm.ru/'; 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(){ } 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 = 'https://creditodobren.amocrm.ru/private/api/v2/json/accounts/current') { $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'])) ) ) ) ); } 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() { $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.0080.00618.42
8.3.50.0120.00722.10
8.3.40.0000.01518.67
8.3.30.0140.00419.04
8.3.20.0070.00020.29
8.3.10.0050.00322.00
8.3.00.0000.00922.45
8.2.180.0090.00616.50
8.2.170.0040.01122.96
8.2.160.0070.01020.81
8.2.150.0040.00424.18
8.2.140.0000.00924.66
8.2.130.0040.00426.16
8.2.120.0060.00319.26
8.2.110.0030.00621.00
8.2.100.0070.00417.78
8.2.90.0040.00419.06
8.2.80.0000.00817.97
8.2.70.0000.00817.50
8.2.60.0040.00417.93
8.2.50.0000.00918.07
8.2.40.0050.00318.22
8.2.30.0080.00018.07
8.2.20.0000.00717.59
8.2.10.0050.00317.75
8.2.00.0030.00517.75
8.1.280.0150.00325.92
8.1.270.0000.00823.97
8.1.260.0040.00426.35
8.1.250.0100.01028.09
8.1.240.0060.00321.09
8.1.230.0040.00722.23
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0030.00617.35
8.1.190.0050.00317.39
8.1.180.0030.00618.10
8.1.170.0030.00518.52
8.1.160.0040.00422.02
8.1.150.0050.00318.66
8.1.140.0080.00017.39
8.1.130.0000.00817.79
8.1.120.0000.00717.46
8.1.110.0000.00817.41
8.1.100.0050.00317.35
8.1.90.0000.00817.31
8.1.80.0070.00017.38
8.1.70.0030.00317.41
8.1.60.0060.00317.59
8.1.50.0000.00817.40
8.1.40.0090.00017.47
8.1.30.0040.00417.62
8.1.20.0050.00317.51
8.1.10.0040.00417.50
8.1.00.0050.00317.42
8.0.300.0080.00018.77
8.0.290.0080.00017.05
8.0.280.0070.00018.32
8.0.270.0030.00617.28
8.0.260.0030.00316.79
8.0.250.0000.00716.88
8.0.240.0020.00516.88
8.0.230.0000.00816.90
8.0.220.0030.00316.76
8.0.210.0040.00416.81
8.0.200.0060.00316.89
8.0.190.0070.00316.83
8.0.180.0000.00716.88
8.0.170.0040.00416.84
8.0.160.0000.00716.85
8.0.150.0000.00716.76
8.0.140.0050.00216.85
8.0.130.0030.00313.32
8.0.120.0070.00414.98
8.0.110.0090.00215.08
8.0.100.0090.00115.07
8.0.90.0050.00615.13
8.0.80.0080.00815.03
8.0.70.0090.00214.99
8.0.60.0080.00315.06
8.0.50.0090.00315.07
8.0.30.0100.00415.64
8.0.20.0090.01016.05
8.0.10.0090.00215.10
8.0.00.0090.00515.54
7.4.330.0050.00015.07
7.4.320.0000.00616.65
7.4.300.0030.00316.48
7.4.290.0040.00416.47
7.4.280.0000.00716.38
7.4.270.0000.00816.48
7.4.260.0000.00816.45
7.4.250.0040.00314.82
7.4.240.0090.00115.43
7.4.230.0040.00414.89
7.4.220.0070.00814.80
7.4.210.0090.00715.73
7.4.200.0050.00614.89
7.4.190.0050.00514.82
7.4.180.0050.00213.25
7.4.160.0060.00614.70
7.4.150.0090.00515.32
7.4.140.0090.00716.29
7.4.130.0090.00815.20
7.4.120.0050.00915.32
7.4.110.0120.00214.77
7.4.100.0040.01014.88
7.4.90.0050.00914.80
7.4.80.0060.00616.24
7.4.70.0070.00514.78
7.4.60.0050.00714.71
7.4.50.0030.00614.79
7.4.40.0050.00817.78
7.4.30.0070.00514.63
7.4.20.0000.00713.10
7.4.10.0060.00013.11
7.4.00.0030.00914.05
7.3.330.0000.00613.13
7.3.320.0030.00313.13
7.3.310.0030.00314.43
7.3.300.0040.00314.69
7.3.290.0050.00714.74
7.3.280.0070.00815.48
7.3.270.0070.00815.25
7.3.260.0070.00614.79
7.3.250.0060.00915.35
7.3.240.0070.00614.70
7.3.230.0020.01014.58
7.3.220.0060.00312.97
7.3.210.0030.01014.65
7.3.200.0050.00816.19
7.3.190.0050.01114.76
7.3.180.0080.00314.79
7.3.170.0030.00814.71
7.3.160.0090.00514.61
7.3.150.0030.00313.00
7.3.140.0060.00013.20
7.3.130.0030.00312.98
7.3.120.0050.00614.03
7.3.110.0040.00413.13
7.3.100.0000.00713.17
7.3.90.0000.00613.45
7.3.80.0060.00013.18
7.3.70.0030.00313.18
7.3.60.0000.00813.34
7.3.50.0050.00213.22
7.3.40.0000.00613.38
7.3.30.0030.00313.37
7.3.20.0040.00415.11
7.3.10.0050.00214.94
7.3.00.0080.00014.89
7.2.340.0080.00313.05
7.2.330.0100.00614.90
7.2.320.0090.01014.90
7.2.310.0130.00514.95
7.2.300.0120.00314.99
7.2.290.0140.00214.66
7.2.280.0090.00313.10
7.2.270.0100.00313.22
7.2.260.0050.00513.25
7.2.250.0120.00013.18
7.2.240.0000.00713.06
7.2.230.0100.00313.30
7.2.220.0130.00013.28
7.2.210.0090.00313.26
7.2.200.0080.00713.38
7.2.190.0090.00413.23
7.2.180.0140.00013.15
7.2.170.0120.00013.25
7.2.160.0100.00313.40
7.2.150.0110.00415.11
7.2.140.0040.00814.98
7.2.130.0110.00415.08
7.2.120.0080.00515.18
7.2.110.0110.00415.17
7.2.100.0060.00615.16
7.2.90.0130.00015.19
7.2.80.0130.00014.99
7.2.70.0120.00015.14
7.2.60.0100.00415.95
7.2.50.0070.00715.21
7.2.40.0120.00415.21
7.2.30.0070.00715.17
7.2.20.0120.00315.23
7.2.10.0150.00015.24
7.2.00.0040.00717.13
7.1.330.0120.00014.15
7.1.320.0060.00614.14
7.1.310.0110.00013.93
7.1.300.0070.00614.14
7.1.290.0080.00414.21
7.1.280.0120.00014.22
7.1.270.0090.00314.05
7.1.260.0130.00014.22
7.1.250.0090.00313.96
7.1.240.0070.00714.14
7.1.230.0040.00814.22
7.1.220.0080.00514.01
7.1.210.0090.00314.21
7.1.200.0060.00614.82
7.1.190.0060.00614.21
7.1.180.0030.00914.00
7.1.170.0110.00014.13
7.1.160.0000.01413.96
7.1.150.0110.00214.11
7.1.140.0080.00414.10
7.1.130.0110.00213.96
7.1.120.0150.00014.01
7.1.110.0120.00213.99
7.1.100.0080.00415.71
7.1.90.0070.00714.10
7.1.80.0090.00214.23
7.1.70.0050.00715.35
7.1.60.0100.00416.98
7.1.50.0030.01315.45
7.1.40.0100.00214.16
7.1.30.0070.00514.09
7.1.20.0120.00013.86
7.1.10.0140.00014.09
7.1.00.0030.04318.29
7.0.330.0120.00013.88
7.0.320.0090.00313.77
7.0.310.0100.00313.93
7.0.300.0120.00014.00
7.0.290.0090.00413.79
7.0.280.0140.00014.05
7.0.270.0090.00513.97
7.0.260.0100.00214.06
7.0.250.0090.00513.97
7.0.240.0090.00314.21
7.0.230.0060.00614.27
7.0.220.0000.01314.03
7.0.210.0040.00814.10
7.0.200.0120.00015.44
7.0.190.0110.00214.03
7.0.180.0140.00014.10
7.0.170.0060.00614.15
7.0.160.0060.00613.87
7.0.150.0060.00614.01
7.0.140.0020.04318.03
7.0.130.0110.00313.95
7.0.120.0120.00013.91
7.0.110.0110.00013.89
7.0.100.0100.00313.90
7.0.90.0120.02316.94
7.0.80.0100.03816.98
7.0.70.0080.02317.06
7.0.60.0090.02417.13
7.0.50.0080.04616.99
7.0.40.0060.02317.02
7.0.30.0130.03717.05
7.0.20.0110.02517.04
7.0.10.0110.03217.06
7.0.00.0080.02217.07
5.6.400.0000.01212.51
5.6.390.0120.00012.36
5.6.380.0110.00012.40
5.6.370.0060.00612.56
5.6.360.0000.01112.40
5.6.350.0060.00612.67
5.6.340.0090.00212.66
5.6.330.0090.00312.35
5.6.320.0050.00512.55
5.6.310.0060.00612.50
5.6.300.0040.00712.56
5.6.290.0100.00212.62
5.6.280.0030.03816.81
5.6.270.0070.00012.55
5.6.260.0050.00012.61
5.6.250.0000.00612.46
5.6.240.0070.04216.67
5.6.230.0100.04016.76
5.6.220.0060.04316.65
5.6.210.0100.03416.63
5.6.200.0050.02616.82
5.6.190.0030.02316.92
5.6.180.0070.03916.80
5.6.170.0040.02916.92
5.6.160.0090.04716.90
5.6.150.0130.03516.83
5.6.140.0090.02016.77
5.6.130.0090.03016.87
5.6.120.0100.02516.82
5.6.110.0030.04516.86
5.6.100.0050.02316.81
5.6.90.0050.04016.71
5.6.80.0060.04516.54
5.6.70.0110.03816.48
5.6.60.0100.02216.54
5.6.50.0050.03716.60
5.6.40.0060.02816.54
5.6.30.0020.02116.58
5.6.20.0100.03416.58
5.6.10.0070.03216.39
5.6.00.0070.02516.40
5.5.380.0140.03816.42
5.5.370.0120.03216.48
5.5.360.0080.02716.37
5.5.350.0110.04016.52
5.5.340.0060.02616.62
5.5.330.0090.02016.68
5.5.320.0090.03816.73
5.5.310.0150.03616.70
5.5.300.0060.02416.68
5.5.290.0100.04316.69
5.5.280.0070.04516.52
5.5.270.0070.03316.69
5.5.260.0100.03516.72
5.5.250.0060.03516.68
5.5.240.0060.03016.34
5.5.230.0000.04516.39
5.5.220.0020.02816.44
5.5.210.0080.02416.39
5.5.200.0070.04216.37
5.5.190.0120.03216.19
5.5.180.0080.02016.28
5.5.170.0090.00512.36
5.5.160.0130.03116.24
5.5.150.0050.02116.31
5.5.140.0060.02016.16
5.5.130.0110.03516.20
5.5.120.0060.02616.11
5.5.110.0160.03316.15
5.5.100.0040.03416.23
5.5.90.0110.03716.29
5.5.80.0040.04516.33
5.5.70.0130.03316.22
5.5.60.0140.03016.25
5.5.50.0090.03516.28
5.5.40.0070.02716.33
5.5.30.0070.02516.21
5.5.20.0100.04116.23
5.5.10.0020.04116.32
5.5.00.0060.03116.27
5.4.450.0050.02715.80
5.4.440.0080.04315.92
5.4.430.0090.03315.88
5.4.420.0060.02116.07
5.4.410.0100.03715.90
5.4.400.0080.04015.87
5.4.390.0070.04315.81
5.4.380.0130.02515.66
5.4.370.0060.02315.70
5.4.360.0100.02515.67
5.4.350.0060.02215.83
5.4.340.0080.03815.75
5.4.330.0090.00212.43
5.4.320.0080.02315.69
5.4.310.0080.03815.76
5.4.300.0060.02315.58
5.4.290.0030.04615.65
5.4.280.0070.03015.66
5.4.270.0080.03615.66
5.4.260.0060.04015.64
5.4.250.0070.02015.75
5.4.240.0070.03815.82
5.4.230.0070.04015.62
5.4.220.0050.03015.63
5.4.210.0100.04015.76
5.4.200.0060.02315.56
5.4.190.0100.03815.49
5.4.180.0080.02315.70
5.4.170.0050.02815.75
5.4.160.0090.03915.63
5.4.150.0110.03515.67
5.4.140.0040.02814.46
5.4.130.0040.04114.40
5.4.120.0030.03014.26
5.4.110.0060.02314.46
5.4.100.0040.02514.37
5.4.90.0070.02114.41
5.4.80.0040.03914.44
5.4.70.0130.03314.51
5.4.60.0060.03314.57
5.4.50.0080.02614.46
5.4.40.0100.02014.39
5.4.30.0030.03414.42
5.4.20.0050.04214.53
5.4.10.0100.03614.40
5.4.00.0030.04114.16
5.3.290.0090.03713.84
5.3.280.0090.03713.83
5.3.270.0130.03513.85
5.3.260.0080.02013.66
5.3.250.0070.04113.73
5.3.240.0090.03013.69
5.3.230.0050.03013.62
5.3.220.0100.03613.62
5.3.210.0110.03713.79
5.3.200.0050.04413.74
5.3.190.0070.03713.77
5.3.180.0080.02513.86
5.3.170.0080.03513.83
5.3.160.0090.04013.89
5.3.150.0070.03813.74
5.3.140.0080.03313.74
5.3.130.0120.03613.70
5.3.120.0080.04013.78
5.3.110.0040.02813.63
5.3.100.0080.02813.41
5.3.90.0050.03513.54
5.3.80.0060.02213.35
5.3.70.0130.02913.39
5.3.60.0100.01813.40
5.3.50.0080.02213.37
5.3.40.0060.03813.39
5.3.30.0070.02513.44
5.3.20.0050.03413.17
5.3.10.0070.03513.15
5.3.00.0170.01713.18

preferences:
54.1 ms | 401 KiB | 5 Q