1. Go to this page and download the library: Download tekintian/pinyin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tekintian / pinyin example snippets
use tekintian\pinyin\PinyinConverter;
// 创建实例
$pinyinConverter = new PinyinConverter();
// 基本转换
$pinyin = $pinyinConverter->convert('你好,世界!');
echo $pinyin; // 输出: ni hao shi jie
// 保留声调
$pinyinWithTone = $pinyinConverter->convert('你好,世界!', ' ', true);
echo $pinyinWithTone; // 输出: nǐ hǎo shì jiè
// 生成URL Slug
$slug = $pinyinConverter->getUrlSlug('你好,世界!');
echo $slug; // 输出: ni-hao-shi-jie
use tekintian\pinyin\unicode\UnihanDataManager;
$manager = new UnihanDataManager();
// 更新Unihan数据
$updated = $manager->updateData();
// 生成数据报告
$report = $manager->generateReport();