PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php class Translation { const DETECT_YA_URL = 'https://translate.yandex.net/api/v1.5/tr.json/detect'; const TRANSLATE_YA_URL = 'https://translate.yandex.net/api/v1.5/tr.json/translate'; private static $key ="AIza1yCf2zgkmk-nRxdbB4gg49M9GZhmFei55uo"; //private $key ="AIza1yCf2zgkmk-nRxdbB4gg49M9GZhmFei55uo"; function __construct() { if (empty(self::$key)) { throw new ErrorException("Field key is required"); } else { echo self::$key; } } public static function translate_text($format="text") { $values = array( 'key' => self::$key, 'text' => htmlspecialchars($_GET["text"]), 'lang' => htmlspecialchars($_GET["lang"]), 'format' => $format == "text" ? 'plain': $format ); echo $values['text']; echo $values['lang']; } } $transl = new Translation(); Translation::translate_text(); //echo $transl->translate_text(); //Translation::translate_text();
Show:  
Copy Clear