thinkphp5.1.18 基于composer安装
首先通过 Composer 安装:
composer require "overtrue/pinyin:~3.0"
然后在文件头部引入
use Overtrue\Pinyin\Pinyin;
比如:
文件路径 Web\application\index\controller\Index.php
内容:
namespace app\index\controller;
use Overtrue\Pinyin\Pinyin;
class Index
{
public function index()
{
$pinyin = new Pinyin();
echo $pinyin->sentence('带着希望去东莞,比到达终点更美好'); //dai zhe xi wang qu dong guan, bi dao da zhong dian geng mei hao
}
}https://github.com/overtrue/pinyin 最佳答案