php calls the google online translation function
from Chinese to English
class Google_API_translator {
public $out = "";
function translate() {
$this->out = "";
$text = urlencode("Computer");//The word to be translated
$google_translator_url = "http://translate.google.com /translate_a/t?client=t&text=".$text."&sl=zh_CN&tl=en";
echo $google_translator_url;
$gphtml = $this->postPage(array("url" => $google_translator_url));
$this->out = $gphtml;
return $this->out; ) {
$html = "";
if($opts["url"] != "") {
curl_setopt($ch, CURLOPT_URL, $opts["url"]);
$html = curl_exec($ch);
if(curl_errno($ch)) $html = " ";
curl_close ($ch);$g->translate();
class Google_API_translator {
$this->out = ""; $text = urlencode("computer");//The word to be translated
$google_translator_url = "http://translate.google.com/translate_a/t?client=t&text=".$text."&sl=en&tl=zh_CN";//Piece together the google translation api url $this-> $this->out; }
function postPage($opts) {
if($opts["url"] != "") {
$ch = curl_init(); >
if(curl_errno($ch)) $html = "";
curl_close ($ch); }
$g->translate();
It’s perfect, there are no encoding issues in the returned results. The Chinese encoding returned from Google is completely correct.
http://www.bkjia.com/PHPjc/445043.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/445043.html
TechArticle
php calls the google online translation function from Chinese to English class Google_API_translator { public $out = ; function translate() { $ this-out = ; $text = urlencode(computer);//The word to be translated...