PHP code example of razonyang / php-opencc

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

    

razonyang / php-opencc example snippets



use RazonYang\OpenCC\Config;
use RazonYang\OpenCC\Converter;

try {
    $converter = new Converter(Config::S2T); // 简体转繁体
    echo $converter->convert('你干什么不干我事'); // 你幹什麼不干我事
    $converter->close();
} catch (\Throwable $e) {
    // handle exception.
}
shell
composer