小白教程
所有教程
关于
Search
172.69.6.2
172.69.6.2
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func string wordwrap”的源代码
本页内容
上一节:
Func_string_vsprintf
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:wordwrap()}}[[分类:PHP字符串函数参考手册|100]] = PHP wordwrap() 函数 = [[:分类:PHP字符串函数参考手册]] 按照指定长度对字符串进行折行处理: <sample title="" desc="" lang="php" hererun="1"> <?php $str = "An example of a long word is: Supercalifragulistic"; echo wordwrap($str,15,"<br>\n"); ?> </sample> == 定义和用法 == wordwrap() 函数按照指定长度对字符串进行折行处理。 '''注释:'''该函数可能会在行的开头留下空格。 == 语法 == <pre> wordwrap(string,width,break,cut) </pre> {| class="table table-striped table-hover" !width="50%"| 参数 !width="50%"| 描述 |- | string | 必需。规定要进行折行的字符串。 |- | width | 可选。规定最大行宽度。默认是 75。 |- | break | 可选。规定作为分隔符使用的字符(字串断开字符)。默认是 "\n"。 |- | cut | 可选。规定是否对大于指定宽度的单词进行折行: * FALSE - 默认。不折行 * TRUE - 折行 |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 如果成功,则返回折行后的字符串。如果失败,则返回 FALSE。 |- | PHP 版本: | 4.0.2+ |- | 更新日志: | 在 PHP 4.0.3 中,新增了 cut 参数。 |} == 更多实例 == == 实例 1 == 使用所有的参数: <sample title="" desc="" lang="php" hererun="1"> <?php $str = "An example of a long word is: Supercalifragulistic"; echo wordwrap($str,15,"<br>n",TRUE); ?> </sample> == 实例 2 == 对字符串进行折行: <sample title="" desc="" lang="php" hererun="1"> <?php $str = "An example of a long word is: Supercalifragulistic"; echo wordwrap($str,15); ?> </sample> 上面代码的 HTML 输出如下(查看源代码): <sample title="" desc="" lang="php" hererun="1"> <!DOCTYPE html> <html> <body> An example of a long word is: Supercalifragulistic </body> </html> </sample> 上面代码的浏览器输出如下: <sample title="" desc="" lang="php" hererun="1"> An example of a long word is: Supercalifragulistic </sample> [[:分类:PHP字符串函数参考手册]]
返回至“
Func string wordwrap
”。
上一节:
Func_string_vsprintf