使用 Google AJAX Language API 检测 PHP 语言的最简单方法是什么?

发布于 2024-09-12 08:59:11 字数 72 浏览 1 评论 0原文

有没有一种简单的方法可以使用 Google AJAX Language API 来检测 PHP 语言,而无需使用任何库或巨型框架?

There is an easy way to use the Google AJAX Language API to detect language with PHP without use any library or a giant framework?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光磨忆 2024-09-19 08:59:11

这很容易,

function detect_language($string) {
   $response = file_get_contents("http://www.google.com/uds/GlangDetect?v=1.0&q=" . urlencode($string));
   $response = json_decode($response, true);
   if ($response['responseStatus'] == 200) {
       return $response['responseData']['language'];
   } else {
       return "tw";
   }
}

Thats is easy,

function detect_language($string) {
   $response = file_get_contents("http://www.google.com/uds/GlangDetect?v=1.0&q=" . urlencode($string));
   $response = json_decode($response, true);
   if ($response['responseStatus'] == 200) {
       return $response['responseData']['language'];
   } else {
       return "tw";
   }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文