【发布时间】:2020-08-04 13:04:26
【问题描述】:
我正在尝试使用 PHP 打开、读取和呈现 .txt 文件的内容。
我想用<br> 替换所有新行\n。我可以在 <pre> 标记内回显它,但是当我尝试这种方法时,页面不再响应。
我还想用不同的变量替换上面提到的 { name } 或 $name,例如 python fstrings 的工作原理。
我目前有这个:
echo file_get_contents("file.txt");
这将产生如下所示的东西:
Line1, Line2, Line3, Line4 { Person1 }
我如何让结果看起来像这样
Line1,
Line2,
Line3,
Line4 James
【问题讨论】:
-
欢迎来到 Stack Overflow。请使用tour,阅读what's on-topic,阅读How to Ask a Good Question。