LangModel::_getPhpFile PHP Method

_getPhpFile() private method

写入PHP语言文件
private _getPhpFile ( string $app, array $fields, array $data )
$app string 应用名称
$fields array 语言类型字段
$data array 语言的相关数据
    private function _getPhpFile($app, $fields, $data)
    {
        $app = strtolower($app);
        foreach ($fields as $value) {
            $fileName = LANG_PATH . '/' . $app . '_' . $value . '.php';
            // 权限处理
            $fp = fopen($fileName, 'w+');
            $fileData = "<?php\n";
            $fileData .= "return array(\n";
            foreach ($data as $val) {
                $val[$value] = str_replace("'", '‘', $val[$value]);
                // 处理掉单引号
                $content[] = "'{$val['key']}'=>'{$val[$value]}'";
            }
            $fileData .= implode(",\n", $content);
            $fileData .= "\n);";
            fwrite($fp, $fileData);
            fclose($fp);
            unset($fileData);
            unset($content);
            @chmod($fileName, 0775);
        }
    }