代码分享给大家
<? <BR>/** <BR>* GOOGLE翻译 英汉 <BR>* <BR>* @param string $text 翻译句 <BR>* @return unknown <BR>*/ <BR>function googleTran($text){ <BR> if(empty($text)) return ""; <BR> sleep(1);//反间碟 <BR> $wf=@file_get_contents('http://translate.google.cn/translate_t?sl=en&tl=zh-CN&text='.urlencode($text).'#'); <BR> if (false===$wf||empty($wf)){ <BR> return false; <BR> } <br><br> //截取相关信息 <BR> $return = ""; <BR> $wf=strip_tags($wf,"<div>"); <BR> $star=strpos($wf,"<div id="result_box" dir="ltr">"); <BR> if(false===$star){ <BR> return false; <BR> } <BR> $end=strpos($wf,"
“);
if(false===$end)本文来源gaodai#ma#com搞@@代~&码*网/搞gaodaima代码{
return false;
}
$return = strip_tags(substr($wf,$star,$end-$star));
if(false===$end)本文来源gaodai#ma#com搞@@代~&码*网/搞gaodaima代码{
return false;
}
$return = strip_tags(substr($wf,$star,$end-$star));
return iconv(“GB2312″,”UTF-8”,trim($return));
}
?>