Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular

PHPize.online is a free online environment for quickly running, experimenting with and sharing PHP (including Carbon extension for DateTime) and SQL code. You can run your SQL code with PHP code that can use the same DB. For database manipulations you can use pre-defined instances of PDO ($pdo), mysqli ($mysqli) & Laravel query builder ($db)

Copy Format Clear
Copy Clear
Copy Format Clear
<?php sudo apt-get install php-curl <?php $apiKey = 'c24cbb3f-c57e-4cfd-8ed6-29e773bc81b6'; // Замените на ваш собственный API-ключ // Текст, который вы хотите перевести $textToTranslate = "Пресненская набережная, 10 блок С, Москва"; $sourceLanguage = 'ru'; // Язык исходного текста $targetLanguage = 'en'; // Язык, на который вы хотите перевести // Формируем URL для отправки запроса к API Яндекс Переводчика $url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=$apiKey&text=" . urlencode($textToTranslate) . "&lang=$sourceLanguage-$targetLanguage"; // Используем cURL для отправки запроса $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // Разбираем ответ API $data = json_decode($response, true); // Получаем переведенный текст $translatedText = $data['text'][0]; echo "Исходный текст: $textToTranslate<br>"; echo "Переведенный текст: $translatedText";
Show:  
Copy Clear