以下是一个使用PHP读写UTF-8编码文件的详细代码示例:
php复制代码
<?php |
|
// 读取UTF-8文件 |
|
function readUtf8File($filePath) |
|
{ |
|
$content = ''; |
|
$handle = fopen($filePath, 'r'); |
|
if ($handle) { |
|
while (($line = fgets($handle)) !== false) { |
|
// 将每行数据转换为UTF-8编码 |
|
$content .= mb_convert_encoding($line, 'UTF-8', mb_detect_encoding($line)) . PHP_EOL; |
|
} |
|
PHPUTF-8文件读写及编码转换示例,

最低0.47元/天 解锁文章
1201

被折叠的 条评论
为什么被折叠?



