位置: 编程技术 - 正文

PHP字符串函数nl2br()的用法(php字符串函数有哪些)

编辑:rootadmin
nl2br

推荐整理分享PHP字符串函数nl2br()的用法(php字符串函数有哪些),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:php 字符串函数,php字符串函数有哪些,在php中,字符串有哪些表示形式,php字符串定义的三种方式,php字符串赋值,在php中,字符串有哪些表示形式,php 字符串函数,php字符串定义,内容如对您有帮助,希望把文章链接给更多的朋友!

(PHP 4, PHP 5)

nl2br — 在字符串所有新行之前插入 HTML 换行标记

说明 string nl2br ( string $string [, bool $is_xhtml = true ] )

在字符串 string 所有新行之前插入 &#;<br />&#; 或 &#;<br>&#;,并返回。

参数

string

输入字符串。

is_xhtml

是否使用 XHTML 兼容换行符。

返回值

返回调整后的字符串。

范例 PHP字符串函数nl2br()的用法(php字符串函数有哪些)

Example #1 nl2br() 使用范例

<?phpechonl2br("fooisn'tnbar");?>

以上例程会输出:

Example #2 使用 is_xhtml 生成合法的 HTML 标记

<?phpechonl2br("WelcomernThisismyHTMLdocument",false);?>

以上例程会输出:

Example #3 各种换行分隔符

<?php$string="Thisrnisnranstringr";echonl2br($string);?>

以上例程会输出:

更新日志

版本 说明 5.3.0 新增可选的 is_xhtml 参数。 4.0.5 nl2br() 成为 XHTML 兼容的操作。所有的旧版本都会在 string 的新行之前插入 &#;<br>&#; 而不是 &#;<br />&#;。

参见

htmlspecialchars() - Convert special characters to HTML entities htmlentities() - Convert all applicable characters to HTML entities wordwrap() - 打断字符串为指定数量的字串 str_replace() - 子字符串替换

PHP字符串函数nl_langinfo()的用法 nl_langinfo(PHP4=4.1.0,PHP5)nl_langinfoQuerylanguageandlocaleinformation说明stringnl_langinfo(int$item)nl_langinfo()isusedtoaccessindividualelementsofthelocalecategories.Unlikelocaleconv(),whichretu

PHP字符串函数metaphone()的用法 metaphone(PHP4,PHP5)metaphoneCalculatethemetaphonekeyofastring说明stringmetaphone(string$str[,int$phonemes=0])Calculatesthemetaphonekeyofstr.Similartosoundex()metaphonecreatesthesamekeyforsimilarsou

PHP字符串函数levenshtein()的用法 levenshtein(PHP4=4.0.1,PHP5)levenshtein计算两个字符串之间的编辑距离说明intlevenshtein(string$str1,string$str2)intlevenshtein(string$str1,string$str2,int$cost_ins,int$cost_rep,int$cost_

本文链接地址:https://www.jiuchutong.com/biancheng/278853.html 转载请保留说明!

上一篇:PHP字符串函数money_format()的用法(php字符串函数有哪些)

下一篇:PHP字符串函数nl_langinfo()的用法(php字符串定义)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络