PHP调用谷歌翻译
程序员文章站
2022-05-11 22:22:55
...
/*
* PHP调用谷歌翻译
* 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("
* PHP调用谷歌翻译
* 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("
上一篇: Javascript中的类实现
下一篇: 向量时钟算法简介