首页 在线翻译 在线翻译示例代码 翻译[PHP]

翻译示例代码[PHP]

作者: 阅读数:4962 上传时间:2016-03-10

翻译

<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$type = 'google';
$from = 'zh-CN';
$to = 'en';
$text = '好';//utf8
$arr=array('type'=>$type,'from'=>$from,'to'=>$to,'text'=>$text);
$url = "https://api.jisuapi.com/translate/translate?appkey=$appkey";
$result = curlOpen($url, array('post'=>$arr));

$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));

if($jsonarr['status'] != 0)
{
    echo $jsonarr['msg'];
    exit();
}

$result = $jsonarr['result'];
echo $result['result'].'
';