<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<?php

 $out = "";

 $text =urlencode($_GET['s']);//要翻译的单词

 $google="http://translate.google.com/translate_a/t?client=t&text=".$text."&sl=auto&tl=zh-CN";
//echo  $google_translator_url;
//拼凑google翻译的api url         
       // $gphtml = postPage(array("url" => $google_translator_url));
		$code= file_get_contents($google);
		// $st=mb_convert_encoding($code, "UTF-8", "auto");
		 $ss=iconv("GB2312", "UTF-8", $code);
        $html=explode("\",\"",$ss);
  
   $out =ereg_replace("\[\""," ",$html[0]);
echo  $code;
 
 
    function postPage($opts) {
        $html = "";

if($opts["url"] != "") {
            //$ch = curl_init();
			 $ch= curl_init($opts["url"]);
            curl_setopt($ch, CURLOPT_URL, $opts["url"]);

            $html = curl_exec($ch);

 

if(curl_errno($ch)) $html = "";
            curl_close ($ch);
        }

return $html;
    }



 ?>