Home > Backend Development > PHP Tutorial > PHP online translation function code_PHP tutorial

PHP online translation function code_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:46:31
Original
1475 people have browsed it

Share the code with everyone

Copy the code The code is as follows:

/**
* GOOGLE Translation English-Chinese
*
* @param string $text translation sentence
* @return unknown
*/
function googleTran($text){
if(empty($text)) return "";
sleep(1);//return
$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; 🎜> $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));

}
?>





http://www.bkjia.com/PHPjc/320135.html
www.bkjia.com

true

TechArticleThe code is shared with everyone. Copy the code as follows: ? /*** GOOGLE Translate English-Chinese * * @param string $text translation sentence * @return unknown*/ function googleTran($text) { if(empty($text)) retu...
source:php.cn
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template