3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Translation { const DETECT_YA_URL = 'https://translate.yandex.net/api/vl.5/tr.json/detect'; const TRANSLATE_YA_URL = 'https://translate.yandex.net/api/vl.5/tr.json/translate'; public $key = "AIzalyCf2zgkmk-nRxdbB4gg49M9GZhmFei55uo"; public function init(){ parent::init(); if( empty( $this->key ) ) { throw new InvalidConfigException("Field <b>$key</b> is required”); } } /** * @param $format text format need to translate * @return string */ public static function translate_text($format="text") { if (empty($this->key)) { throw new InvalidConfigException("Field <b>$key</b> is required"); } $values = array( 'key' => $this->key, 'text' => $_GET['text'], 'lang' => $_GET['lang'], 'format' => $format == "text" ? 'plain' : $format, ); $formData = http_build_query($values); $ch = curl_init(self::TRANSLATE_YA_URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $formData); $json = curl_exec($ch); curl_close($ch); $data = json_decode($json, true); if($data['code']==200) { return $data['text']; } return $data; } }

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.0.00.0100.00716.80
7.4.130.0090.01216.11
7.4.120.0070.01116.63
7.4.110.0030.01516.51
7.4.100.0130.00616.41
7.4.90.0070.01116.10
7.4.80.0130.01016.37
7.4.70.0100.00716.29
7.4.60.0130.01016.37
7.4.50.0110.00916.48
7.4.40.0120.00616.33
7.4.30.0160.00816.56
7.4.20.0140.00316.39
7.4.10.0120.00616.26
7.4.00.0130.01316.46
7.3.250.0090.00916.09
7.3.240.0070.01116.22
7.3.230.0090.01016.13
7.3.220.0090.00916.18
7.3.210.0030.01416.25
7.3.200.0100.00716.21
7.3.190.0140.00316.22
7.3.180.0000.01716.37
7.3.170.0180.00016.44
7.3.160.0110.01116.23
7.3.150.0100.01016.14
7.3.140.0100.00716.39
7.3.130.0030.01416.37
7.3.120.0070.01716.32
7.3.110.0180.00516.38
7.3.100.0180.00016.17
7.3.90.0070.01016.14
7.3.80.0090.00916.07
7.3.70.0030.01516.20
7.3.60.0150.00316.07
7.3.50.0000.01716.11
7.3.40.0110.00716.16
7.3.30.0110.00716.08
7.3.20.0090.00916.24
7.3.10.0090.00916.16
7.3.00.0060.01516.20

preferences:
149.2 ms | 1000 KiB | 7 Q