PHP 中的文本到 HTML

发布于 2024-09-12 18:22:05 字数 89 浏览 1 评论 0原文

nl2br();可以为 EOL 做,但是行首(或不是)的空格和/或制表符怎么样?有什么函数可以立即执行此操作吗?我需要文本文件的格式良好的 html 输出。 谢谢。

nl2br(); can do for EOL but what about white spaces and/or tabs at the beginning(or not) of line? Is there any function to do this at once? I need well formatted html output of text file.
Thx.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱娆 2024-09-19 18:22:05

很可能

....

可以做到这一点

也可以参见

htmlspecialchars()

http://php.net/manual/en/function.htmlspecialchars.php

htmlentities()

http://www.php.net/manual/en/function.htmlentities.php

well may be <pre>....</pre> can do it

also see

htmlspecialchars()

http://php.net/manual/en/function.htmlspecialchars.php

htmlentities()

http://www.php.net/manual/en/function.htmlentities.php

红尘作伴 2024-09-19 18:22:05

使用“pre”HTML 标签就可以了。

<?php
echo '<pre>' ;
/// .... do text output stuff...
echo '</pre>' ;
?>

抱歉我的蹩脚问题。我是魔兽世界(网络词)的新手。

It is OK to use "pre" HTML tag.

<?php
echo '<pre>' ;
/// .... do text output stuff...
echo '</pre>' ;
?>

Sorry for my lame question. I'm new in WoW(word of web).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文