Ejemplo n.º 1
0
function opecc_convert($file_path)
{
    //check opencc module load correctly.
    $br = php_sapi_name() == "cli" ? "" : "<br>";
    if (!extension_loaded('opencc')) {
        dl('opencc.' . PHP_SHLIB_SUFFIX);
        echo "dl\n";
    }
    $module = 'opencc';
    $functions = get_extension_funcs($module);
    //read file
    $text = file_get_contents($file_path);
    $od = opencc_open("zhs2zht.ini");
    $text = opencc_convert($od, $text);
    opencc_close($od);
    return $text;
}
Ejemplo n.º 2
0
<?php

$br = php_sapi_name() == "cli" ? "" : "<br>";
if (!extension_loaded('opencc')) {
    dl('opencc.' . PHP_SHLIB_SUFFIX);
    echo "dl\n";
}
$module = 'opencc';
$functions = get_extension_funcs($module);
print_r($functions);
$text = "你干什么不干我事。\n";
$od = opencc_open("zhs2zht.ini");
var_dump($od);
$text = opencc_convert($od, $text);
opencc_close($od);
echo $text;
Ejemplo n.º 3
0
<?php

$br = php_sapi_name() == "cli" ? "" : "<br>";
if (!extension_loaded('opencc')) {
    dl('opencc.' . PHP_SHLIB_SUFFIX);
}
$module = 'opencc';
$functions = get_extension_funcs($module);
echo "Functions available in the test extension:{$br}\n";
foreach ($functions as $func) {
    echo $func . "{$br}\n";
}
echo "{$br}\n";
$od = opencc_open('s2twp.json');
echo opencc_convert("我的鼠标哪儿去了?", $od);
echo opencc_error() . "\n";
var_dump(opencc_close($od));