/*
*Google翻译PHP接口
*/$Google=newGoogle();echo $Google->translate('中国','en');classGoogle{public$out="";public$google_translator_url='http://translate.google.com/translate_a/t';public$text='';public$from='';public$to='';functionsetText($text){$this->text=$text;}functiontranslate($text,$to='ru'){$this->out="";$this->text=$text;$this->from='zh_CN';$this->to=$to;$gphtml=$this->postPage();$arr=$this->decode($gphtml,1);if(is_array($arr['sentences'])){foreach($arr['sentences']as$val){$this->out.=$val['trans'];}}return$this->out;}functionpostPage(){$sockfd=socket_create(AF_INET,SOCK_STREAM,getprotobyname("tcp"));$enctext=urlencode($this->text);$post_fields="sl={$this->from}&tl={$this->to}&client=json&