Share the code with everyone
Copy the code The code is as follows:
/**
* GOOGLE Translate English-Chinese
*
* @param string $text translation sentence
* @return unknown
*/
function googleTran($text){
if(empty($text)) return "" ;
sleep(1);//Anti-interval
$wf=@file_get_contents('http://translate.google.cn/translate_t?sl=en&tl=zh-CN&text='.urlencode($text).'#' ; ;div>");
$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 introduces the PHP online translation function code, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn