|
还是想用来做seo中的URL路径
PHP复制代码 <?php
function translate ($text, $language = 'zh-CN|en'){
if (empty($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 (!empty($html)){
$x = explode("</span></span></div></div>", $html);
$x = explode("onmouseout=\"this.style.backgroundColor='#fff'\">", $x[0]);
return $x[1];
}else{
return false;
}
}
//echo translate('公司介绍', 'zh-CN|en');
复制代码 |
评分
-
查看全部评分
|