現在の位置: ホーム> 関数カテゴリ一覧> 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進数文字列をバイナリ文字列に変換します hex2bin

    hex2bin

    16進数文字列をバイナリ文字列に変換しま
  • 8ビット文字列を引用符で印刷可能な文字列に変換します quoted_printable_encode

    quoted_printable_encode

    8ビット文字列を引用符で印刷可能な文字列
  • 文字列の最初と端からスペース(または他の文字)を削除します trim

    trim

    文字列の最初と端からスペース(または他の
  • タグ分割文字列 strtok

    strtok

    タグ分割文字列
  • 特定のファイルのMD5ハッシュ値を計算します md5_file

    md5_file

    特定のファイルのMD5ハッシュ値を計算し
  • htmlspecialchars()およびhtmlentities()を使用した後、変換テーブルを返します get_html_translation_table

    get_html_translation_table

    htmlspecialchars()およ
  • 文字列で使用されている単語に関する情報を返します str_word_count

    str_word_count

    文字列で使用されている単語に関する情報を
  • ファイルのSHA1ハッシュ値を計算します sha1_file

    sha1_file

    ファイルのSHA1ハッシュ値を計算します