命令行版本的中英互译,调用了百度翻译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 <?php $url = 'http://openapi.baidu.com/public/2.0/bmt/translate?client_id=T8Qlsxu4VmLt6qWbqqjtMdLo&q='; isset($argv[1]) or die('至少指定一个词作为参数'.PHP_EOL); $q = $argv; array_shift($q); foreach($q as $k=>$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; } ?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools