In our last class, we introduced the example sharing of php converting Chinese characters to pinyin to get the first letter, then there are also rare characters in our Chinese. Rare characters are also called rare characters, which refer to unknown characters. Common or unfamiliar Chinese characters. Since the emergence of Chinese characters, Chinese characters have been constantly developing and changing. So today I will introduce to you how PHP supports the conversion of rare characters into pinyin!
The first step is to download the PHP Chinese character to Pinyin library that supports rare characters that we need for this course: http://www.php.cn/xiazai/leiku/741
The second step, after the download is completed, find the php class file we need, unzip it to our local directory, and create a new php file!
The third step, after completion, we need to call this class in the new php file and instantiate the class:
<?php include_once "codehanzi.php";//引入文件 $py = new py_class(); //实例化类 //输出结果 echo $py -> str2py("巴彦淖尔市")."<br>"; echo $py -> str2py("php中文网")."<br>"; echo $py -> str2py("叁参叄叅叆叇亝"); ?>
The running results are as follows:
The above is the detailed content of Development example of using PHP to convert Chinese characters into Pinyin for rare characters. For more information, please follow other related articles on the PHP Chinese website!