开发者

What is the easiest way to use Google AJAX Language API to detect language with PHP?

开发者 https://www.devze.com 2023-01-08 22:18 出处:网络
There is an easy way to use the Google AJAX Language API to detect langua开发者_开发百科ge with PHP without use any library or a giant framework?Thats is easy,

There is an easy way to use the Google AJAX Language API to detect langua开发者_开发百科ge with PHP without use any library or a giant framework?


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";
   }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消