1. Go to this page and download the library: Download ysp/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/ */
ysp / pinyin example snippets
use Ysp\Pinyin\Pinyin;
$pinyin = Pinyin::sentence('你好,世界');
use Ysp\Pinyin\Pinyin;
echo Pinyin::sentence('带着希望去旅行,比到达终点更美好');
// dài zhe xī wàng qù lǚ xíng , bǐ dào dá zhōng diǎn gèng měi hǎo
// 去除声调
echo Pinyin::sentence('带着希望去旅行,比到达终点更美好', 'none');
// dai zhe xi wang qu lv xing , bi dao da zhong dian geng mei hao
// 保留所有非汉字字符
echo Pinyin::fullSentence('ル是片假名,π是希腊字母', 'none');
// ル shi pian jia ming ,π shi xi la zi mu