PHP calls Google translate .? Php ** PHP calls Google translate * author: cc * date: 201254 * functiontranslate ($ text, $ languagezh-cn | en) {if (emptyempty ($ text) returnfalse; @ set_time_limit (0); $ html; $ chcur /*
* PHP calls Google translate
* Author: cc
* Date: 2012/5/4
*/
Function translate ($ text, $ language = 'zh-cn | en '){
If (emptyempty ($ text) return false;
@ Set_time_limit (0 );
$ Html = "";
$ Ch = curl_init ("http://google.com/translate_t? Langpair = ". urlencode ($ language)." & text = ". urlencode ($ text ));
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1 );
$ Html = curl_exec ($ ch );
If (curl_errno ($ ch) $ html = "";
Curl_close ($ ch );
If (! Emptyempty ($ html )){
$ X = explode ("
", $ Html );
$ X = explode ("onmouseout = \" this. style. backgroundColor = '# fff' \ ">", $ x [0]);
Return $ x [1];
} Else {
Return false;
}
}
Echo translate ('authorization', 'Kr | zh-cn ');
?>
From the PainsOnline column
Http://www.bkjia.com/PHPjc/478259.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478259.htmlTechArticle? Php/** PHP calls Google translate * author: cc * date: 2012/5/4 */function translate ($ text, $ language = zh-cn | en) {if (emptyempty ($ text) return false; @ set_time_limit (0); $ html =; $ ch = cur...