File: /www/wwwroot/www.baofufacai.com///fy/fy.php
<?php
// 定义翻译源语言和目标语言
$source = 'en'; // 源语言为英文
$target = 'zh-CN'; // 目标语言为简体中文
// 获取待翻译的文本
$text = 'Hello, world!';
// 构造谷歌翻译API的请求URL
$url = 'https://translation.googleapis.com/language/translate/v2?key=AIzaSyApV2SnkzCF9mrXDZqyM8mbvZpU-q0kS84&q=' . urlencode($text) . '&source=' . $source . '&target=' . $target;
// 发送HTTP请求并获取响应
$response = file_get_contents($url);
// 解析JSON格式的响应数据
$data = json_decode($response, true);
// 提取翻译结果
$translation = $data['data']['translations'][0]['translatedText'];
// 输出翻译结果
echo $translation;
?>