1. Go to this page and download the library: Download chineseboost/php-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/ */
chineseboost / php-pinyin example snippets
use Pinyin\Hanzi\HanziSentence;
(new HanziSentence('科学家的工作就是对理论加以检验。'))->asPinyin()->toneMarked();
// "Kēxuéjiā de gōngzuò jiùshì duì lǐlùn jiāyǐ jiǎnyàn."
(new HanziSentence('他下了车,扑哧扑哧地穿过泥地去开门。'))->asPinyin()->toneMarked();
// "Tā xià le chē, pū chī pū chī de chuānguò ní dì qù kāimén."
(new HanziSentence('我兒子真的是一點兒生活常識都沒有!'))->asPinyin()->toneMarked();
// "Wǒ érzi zhēn de shì yīdiǎnr shēnghuó chángshí dōu méiyǒu!"
(new HanziSentence('食品供给'))->asPinyin()->toneMarked();
// "Shípǐn gōngjǐ"
(new HanziSentence('政府将在2015年对旅游行业加以规范。'))->asPinyin()->toneMarked();
// "Zhèngfǔ jiāng zài èr líng yī wǔ nián duì lǚyóu hángyè jiāyǐ guīfàn."
(new HanziSentence('我已经累得不得了了。'))->asPinyin()->toneMarked();
// "Wǒ yǐjīng lèi de bùdéliǎo le."