Code share to Everyone
Copy the Code code as follows:
/**
* Google Translate English-Chinese
*
* @param string $text translation sentences
* @return Unknown
*/
function Googletran ($text) {
if (empty ($text)) return "";
Sleep (1);//Spyalectical Disc
$WF = @file_get_contents (' http://translate.google.cn/translate_t?sl=en&tl=zh-CN&text= '. UrlEncode ($text). ' #');
if (false=== $wf | | Empty ($WF)) {
return false;
}
Intercept related information
$return = "";
$WF =strip_tags ($WF, "");
$star =strpos ($WF, "");
if (false=== $star) {
return false;
}
$end =strpos ($WF, "");
if (false=== $end) {
return false;
}
$return = Strip_tags (substr ($WF, $star, $end-$star));
Return Iconv ("GB2312", "UTF-8", Trim ($return));
}
?>
The above describes the PHP translation function code, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.