中文转拼音

浏览:1776 发布日期:2017/07/04 分类:技术分享 关键字: php 中文转拼音 thinkphp3.2.3 composer
使用环境
thinkphp3.2.3 基于composer安装


使用过程
tip: "overtrue/pinyin": "~3.0" 主要添加了这段

{
"name": "topthink/thinkphp",
"description": "the ThinkPHP framework",
"type": "framework",
"keywords": ["framework","thinkphp","ORM"],
"homepage": "http://thinkphp.cn/",
"license": "Apache2",
"authors": [
{
"name": "liu21st",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3.0",
"filp/whoops": "^2.1",
"overtrue/pinyin": "~3.0"
},
"minimum-stability": "dev"
}
执行命令: composer update

thinkphp控制器中使用

<?php
require $_SERVER['DOCUMENT_ROOT'].__ROOT__.'/vendor/autoload.php';
$pinyin->convert('我是中文'); //取拼音
$pinyin->abbr('我是中文'); //取首字母

文章更新地址

http://www.majianwei.com/php%E4%B8%AD%E6%96%87%E8%BD%AC%E6%8B%BC%E9%9F%B3/

最佳答案
评论( 相关
后面还有条评论,点击查看>>