TP5.1 Overtrue的中文转拼音

浏览:2381 发布日期:2018/07/05 分类:ThinkPHP5专区
使用环境
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
最佳答案
评论() 相关
后面还有条评论,点击查看>>