好好学习,天天"/>
PHP头条
热点:

linuxshell里,输入enhello,返回你好,反之亦然。-PHP源码


命令行版本的中英互译,调用了百度翻译API。

$en how are you
how -> 怎么用
are -> 是
you -> 你
$en "how are you"
how are you -> 好好学习,天天向上
$en 好好学习,天天向上
好好学习,天天向上 -> Study hard and make progress every day

需要php-cli支持:

sudo yum install php-cli

需要赋予执行权限:

chmod a+x en

#!/bin/php
$v){
 $q[$k]= urlencode($v);
}
$json = file_get_contents($url.implode('%0A',$q));
$arr=json_decode($json,true);
$arr = $arr['trans_result'];
foreach ($arr as $key) {
 $cmd='echo -ne"e[44;37;5m '.$key['dst'].' 33[0m"';
 echo"${key['src']} ->".exec($cmd);
 echo PHP_EOL;
}
?>

www.phpzy.comtrue/php/35749.htmlTechArticlelinuxshell里,输入enhello,返回你好,反之亦然。-PHP源码 命令行版本的中英互译,调用了百度翻译API。 $en how are you how -> 怎么用 are -> 是 you -> 你 $en "how are you" how are you -> 好好学习,天天...

相关文章

PHP之友评论

今天推荐