admin管理员组文章数量:1532656
Warning: strncmp() has been disabled for security reasons in /www/web/default/blog/public_html/wp-includes/formatting.php on line 117
Warning: strncmp() has been disabled for security reasons in /www/web/default/blog/public_html/wp-includes/formatting.php on line 117
Warning: strncmp() has been disabled for security reasons in /www/web/default/blog/public_html/wp-includes/formatting.php on line 117
Warning: strncmp() has been disabled for security reasons in /www/web/default/blog/public_html/wp-includes/formatting.php on line 117
php利用谷歌实现自动翻译,以下是两种实现的方式,php文档用utf8就不会出现乱码问题
第一种利用curl:
function translate($text,$language='zh-cn|en'){
if(empty($text))return false;
@set_time_limit(0);
$html = "";
$ch=curl_init("http://google/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("
",$html);版权声明:本文标题:php在线翻译,php利用谷歌实现自动在线翻译 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1725597656a1032041.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论