小白教程
所有教程
关于
Search
172.69.6.142
172.69.6.142
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func string nl2br”的源代码
本页内容
上一节:
Func_string_nl_langinfo
下一节:
Func_string_number_format
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:nl2br()}}[[分类:PHP字符串函数参考手册|35]] = PHP nl2br() 函数 = [[:分类:PHP字符串函数参考手册]] 在字符串中的新行(\n)之前插入换行符: <sample title="" desc="" lang="php" hererun="1"> <?php echo nl2br("One line.\nAnother line."); ?> </sample> 上面代码的浏览器输出如下: <sample title="" desc="" lang="php" hererun="1"> One line. Another line. </sample> 上面代码的 HTML 输入如下(查看源代码): <sample title="" desc="" lang="php" hererun="1"> One line.<br /> Another line. </sample> == 定义和用法 == nl2br() 函数在字符串中的每个新行(\n)之前插入 HTML 换行符(<br> 或 <br />)。 == 语法 == <pre> nl2br(string,xhtml) </pre> {| class="table table-striped table-hover" !width="50%"| 参数 !width="50%"| 描述 |- | string | 必需。规定要检查的字符串。 |- | xhtml | 可选。一个表示是否使用兼容 XHTML 换行的布尔值: * TRUE- 默认。插入 <br /> * FALSE - 插入 <br> |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 返回已转换的字符串。 |- | PHP 版本: | 4+ |- | 更新日志: | 在 PHP 4.0.5 之前,该函数插入 <br>。在 PHP 4.0.5 之后,该函数插入兼容 XHTML 的 <br />。在 PHP 5.3 中,新增了 xhtml 参数。 |} == 更多实例 == == 实例 1 == 通过使用 xhtml 参数,在新行(\n)之前插入换行符: <sample title="" desc="" lang="php" hererun="1"> <?php echo nl2br("One line.\nAnother line.",false); ?> </sample> 上面代码的浏览器输出如下: <sample title="" desc="" lang="php" hererun="1"> One line. Another line. </sample> 上面代码的 HTML 输入如下(查看源代码): <sample title="" desc="" lang="php" hererun="1"> One line.<br> Another line. </sample> [[:分类:PHP字符串函数参考手册]]
返回至“
Func string nl2br
”。
上一节:
Func_string_nl_langinfo
下一节:
Func_string_number_format