//MFB_CH.php
<?php
class MFB_CH{
static function GetMFB_ChTxt($index)
{
if(array_key_exists($index,self::$MFB_ChTxt))
{
return self::$MFB_ChTxt[$index];
}else{
return "";
}
}
//汉化准备
private static $MFB_ChTxt = array("Title"=>"Hello",
"Age"=>"World");
}
?>
//test.php
<?php include'MFB_CH.php';
//需要汉化的文件
//测试 1、key 存在时和key不存在时
echo MFB_CH::GetMFB_ChTxt('Title');
$test = MFB_CH::GetMFB_ChTxt('test');
if($test == ""){
echo "this key is not exit in the array";
}
?>