PHP nl2br

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP : nl2br() function

Description

The nl2br() function is used to insert HTML line breaks ('
') before all newlines ( ) in a string.

Version

(PHP 4 and above)

Syntax

nl2br(input_string)

Parameter

Name

Description

Required /
Optional

Type

input_string

The input string

Required

String

is_xhtml

Whether XHTML compatible line breaks will be used or not.

Optional

Boolean

Return value

Returns the altered string.

Value Type : String.

Pictorial Presentation

php-string-nl2br()

Example :

  1. echo nl2br("w3resource  .  com");  

  2. ?>  

Output :

w3resource 

com