function duwenben($xlujing, $bianma) { $file_path = $xlujing; if (file_exists($file_path)) { $str = file_get_contents($file_path, false, null); // 使用默认的文件编码进行读取 if (strpos($bianma, "gbk") === false) { $str = mb_convert_encoding($str, 'UTF-8', 'GBK'); // 转换为UTF-8编码 } $str = str_replace("\r\n", "<br />", $str); echo $str; } }