PHP - nl2br 函式



語法

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

定義和用法

它在字串中所有換行符前插入 HTML 換行符。

返回值

它返回修改後的字串。

引數

序號 引數和描述
1

string

包含輸入字串的資訊。

2

is_xhtml

包含是否使用 XHTML 相容換行符的資訊。

示例

嘗試以下示例

<?php
   echo nl2br("Tutorialspoint.\nAnother line."); 
?>

這將產生以下結果:

Tutorialspoint
Another line.
php_function_reference.htm
廣告