NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - nl2br

Trieda

Koreň \ Bez triedy

Metóda - nl2br

(PHP 4, PHP 5, PHP 7)

The nl2br() function replaces end of lines (\n) with the <br /> tag. This can be useful for printing texts that may be provided by users within textarea.

Procedurálne

  • function nl2br (string $string, bool $is_xhtml = true) : string

Parametre

NázovDátový typPredvolená hodnotaPopis
$stringstring

The string to replace.

$is_xhtmlbool true

Whether to insert XHTML symbols. The default value is TRUE. Which means that the <br /> will be used. If the value is FALSE, the <br> is used instead.

Mávratovej hodnoty

Vracia: string

A string with HTML tags as a line break.

Príklady

<?php
$s = "Hello there,\nwelcome here!";
echo nl2br($s);

Súvisiace manuály

      • function htmlspecialchars (string $string, int $flags = ENT_COMPAT | ENT_HTML401, string $encoding = ini_get("default_charset"), bool $double_encode = true) : string
      • function str_replace (mixed $search, mixed $replace, mixed $subject, int &$count) : mixed
      Aktivity