• PHP Video Tutorials

PHP - Function nl2br



Syntax

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

Definition and Usage

It Inserts HTML line breaks before all newlines in a string

Return Values

It returns the altered string.

Parameters

Sr.No Parameters & Description
1

string

It contains the information about input string.

2

is_xhtml

It contains the information about whether to use XHTML compatible line breaks or not.

Example

Try out the following example

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

This will produce following result −

Tutorialspoint
Another line.
php_function_reference.htm
Advertisements