It is an inbuilt function of PHP. nl2br() function inserts HTML ( <br> or </ br> ) line breaks before all newlines in a string.
[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|left|left|left”]
Name, Required /Optional, Value Type, Description
string, Required, String, It is the input string.
xhtml_use, Optional, Integer , It decides Either XHTML compatible line breaks to be used or not. Only boolean values can used here. By default its set to TRUE and it will insert <br /> . We can also set it to FALSE and it will Inserts <br>.
[/table]
It returns the altered string after adding HTML line breaks before all newlines.
[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Version, Description
PHP 5.3.0 , Added the optional is_xhtml parameter. Before this version ‘<br />’ was always inserted.
[/table]
<?php echo nl2br("www.\ntutorialmines.\nnet"); ?>
Output of above code in the browser is as below:
HTML output of above code in the browser (View Source) is as below:
<?php echo nl2br("www.\ntutorialmines.\nnet", false); ?>
Output of above code in the browser is as below:
HTML output of above code in the browser (View Source) is as below:
www.<br />
tutorialmines.<br />
net
App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…
As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…
Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…
COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…
Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…
For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…