function mymemorycevir($text,$from,$to){$url='http://api.mymemory.translated.net/get?q='.rawurlencode($text).'&langpair='.$from.'|'.$to;$ch = curl_init($url);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);curl_setopt($ch, CURLOPT_TIMEOUT, 120);curl_setopt($ch, CURLOPT_URL, $url);$html = curl_exec($ch);curl_close($ch);$j=json_decode($html,true);return $j["responseData"]["translatedText"];}
Kullanımı
·echo mymemorycevir("What is your name","EN","TR");