現在の位置: ホーム> 関数カテゴリ一覧> nl2br

nl2br

文字列のすべての新しい行の前にhtml newlineタグを挿入します
名前:nl2br
カテゴリ:
対応言語:php
一言説明:文字列内の各新しい行の前にhtml newlinesを挿入します。

例1

文字列に新しい行(\ n)の前に新しいラインを挿入します。

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">nl2br</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"1つの線。\ nanother line。"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

上記のコードのブラウザ出力:

 1行。
別の行。

上記のコードのHTML入力(ソースコードを参照):

 1つの行。<br />
別の行。

自分で試してみてください

例2

XHTMLパラメーターを使用して、新しい行(\ n)の前に新しいラインを挿入します。

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">nl2br</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"1つの線。\ nanother line。"</span> <span class="token punctuation">、</span> <span class="token constant boolean">false</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

上記のコードのブラウザ出力:

 1行。
別の行。

上記のコードのHTML入力(ソースコードを参照):

 1つの行。<br>
別の行。

自分で試してみてください

類似の関数
  • バイナリデータを16進表現に変換します bin2hex

    bin2hex

    バイナリデータを16進表現に変換します
  • 文字列でサブストリングの最初の発生を見つけます strpos

    strpos

    文字列でサブストリングの最初の発生を見つ
  • 文字列の最初の文字を大文字に設定します ucfirst

    ucfirst

    文字列の最初の文字を大文字に設定します
  • サブストリングの交換 str_replace

    str_replace

    サブストリングの交換
  • 論理 -  hebrewをビジュアルヘブライ語に変換します hebrev

    hebrev

    論理-hebrewをビジュアルヘブライ語
  • 文字列の最初と端からスペース(または他の文字)を削除します trim

    trim

    文字列の最初と端からスペース(または他の
  • 破裂のエイリアス join

    join

    破裂のエイリアス
  • 症例感受性STRSTR stristr

    stristr

    症例感受性STRSTR