Monday, 29 September 2014

nl2br in PHP

PHP nl2br() function is utilized to adds HTML line breaks ('<br />')  before all  newline (\n) in a specified string.

Syntax:

nl2br(string)
string : Required. Defines the  input string.

 Example:

<?php
echo nl2br("My name is\nJohn.");
?>
Output will be:
My name is 
John.
The HTML source code will look like this :
<html>
<body>
My name is<br />
John.
</body>
</html>

0 comments:

Post a Comment