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; } }
Output for 8.0.0
Parse error: syntax error, unexpected identifier "text", expecting ")" in /in/5gvQt on line 23
Process exited with code 255.
Output for 7.3.0 - 7.3.25, 7.4.0 - 7.4.13
Parse error: syntax error, unexpected 'text' (T_STRING), expecting ')' in /in/5gvQt on line 23
Process exited with code 255.

preferences:
174.13 ms | 1004 KiB | 7 Q