汉子转拼音带音标_php博客 首 页 文章列表
教程:汉子转拼音代码分析 内容:
拼 class=btn id=pinyin/>
powered by sucaihuo.com 本站皆为作者原创,转载请注明原文链接:liqingbo.cn
当我们输入所要转换的汉字后,将数据提交到pinyin.php文件进行转换,在返回到index.html文件中
完整代码:
public function pinyin(){ if(is_post){ header(content-type:text/html;charset=utf-8); include(application.common/chinesepinyin.class.php); $pinyin = new chinesepinyin(); $str = $_post['str']; if(strlen($str)transformwithtone($str); $pinyin2 = $pinyin->transformwithouttone($str); $pinyin3 = $pinyin->transformucwordsonlychar($str); $pinyin4 = $pinyin->transformucwords($str); echo '带声调的汉语拼音: '.$pinyin1.''; echo '
'; echo '无声调的汉语拼音: '.$pinyin2.''; echo '
'; echo '首字母只包括汉字: '.$pinyin3.''; echo '
'; echo '首字母和其他字符: '.$pinyin4.''; echo '
'; exit; } $this->display('pinyin'); }
以上例子为thinkphp框架下的
实例效果:汉子转拼音带音标