\n 在文本区域中不起作用
<textarea rows="18" cols="80" style="resize:none;">
<?php
$str = str_replace('<br>', '\n', 'some text<br><br>another line of text');
echo($str);
?>
</textarea>
输出是
some text\n\nanother line of text
这是我想要的输出。
some text
another line of text
有谁知道问题出在哪里吗? 提前致谢
<textarea rows="18" cols="80" style="resize:none;">
<?php
$str = str_replace('<br>', '\n', 'some text<br><br>another line of text');
echo($str);
?>
</textarea>
Output is
some text\n\nanother line of text
This is the output that i want.
some text
another line of text
Anyone know wheres the problem?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
单引号中的反斜杠按字面意思解释。您想要双引号:
有关在 php 中编写字符串文字的不同方法的详细信息,请参阅 官方文档。
Backslashes in single quotes are interpreted literally. You want double quotes:
For details about the different ways to write string literals in php, refer to the official documentation.