PHP code example of xiaodi / think-pinyin

1. Go to this page and download the library: Download xiaodi/think-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/ */

    

xiaodi / think-pinyin example snippets


var_dump(pinyin('带着希望去旅行,比到达终点更美好'));
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing", "bi", "dao", "da", "zhong", "dian", "geng", "mei", "hao"]

var_dump(pinyin_abbr('带着希望去旅行,比到达终点更美好'));
// dzxwqlxbddzdgmh

var_dump(pinyin_permalink('带着希望去旅行,比到达终点更美好'))
// dai-zhe-xi-wang-qu-lyu-xing-bi-dao-da-zhong-dian-geng-mei-hao

var_dump(pinyin_sentence('带着希望去旅行,比到达终点更美好'))
// daizhexiwangqulyuxing,bidaodazhongdiangengmeihao

use xiaodi\ThinkPinyin\Pinyin;

Pinyin::convert();
Pinyin::abbr();
Pinyin::permalink();
Pinyin::sentence();

use think\Controller;

class Index extends Controller
{
  $this->app->pinyin->convert('带着希望去旅行,比到达终点更美好');
}


use app\BaseController

class Index extends BaseController
{
  $this->app->pinyin->convert('带着希望去旅行,比到达终点更美好');
}