解决php读取txt文件时的换行问题

关键在于将换行符转换为
,实现代码:

$info=str_replace("\r\n","
"
,$info);

完整示例如下:


function get_post($path)
{
    echo "\r\n";
    $fd = fopen($path, "r") or die("章节不存在!");
    $info = fread($fd,filesize($path));
    $info=str_replace("\r\n","
"
,$info); echo $info; fclose($fd); } ?>

你可能感兴趣的:(后端,Web全栈开发学习笔记)