# PHP nl2br
**Published by:** [zero](https://paragraph.com/@zero-2/)
**Published on:** 2021-10-12
**URL:** https://paragraph.com/@zero-2/php-nl2br
## Content
(PHP 4, PHP 5, PHP 7, PHP 8) nl2br — 在字符串所有新行之前插入 HTML 换行标记说明nl2br(string $string, bool $is_xhtml = true): string 在字符串 string 所有新行之前插入
或
,并返回。参数string 输入字符串。 is_xhtml 是否使用 XHTML 兼容换行符。返回值返回调整后的字符串。范例示例 #1 nl2br() 使用范例 以上例程会输出:foo isn't<br /> bar
## Publication Information
- [zero](https://paragraph.com/@zero-2/): Publication homepage
- [All Posts](https://paragraph.com/@zero-2/): More posts from this publication
- [RSS Feed](https://api.paragraph.com/blogs/rss/@zero-2): Subscribe to updates
- [Twitter](https://twitter.com/bob_sudo): Follow on Twitter