note 98230 deleted from function.nl2br by danbrown

From: Date: Thu, 03 Jun 2010 13:16:46 +0000
Subject: note 98230 deleted from function.nl2br by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169851@lists.php.net to get a copy of this message
Note Submitter: derek at darkcolors dot com ---- If there is a line break within a tag, nl2br does insert the <br>, but it will first close the tag before it does so: <? $string = <<<end <a href="http://google.com" target="_blank"> end; $string = nl2br($string); echo $string; ?> This will output the following HTML (notice the extra > sign that gets added before the new <br /> tag): <a href="http://whatever.com"><br /> target="_blank"><br /> This means nl2br does not simply add <br /> before every \n. It is actively checking and closing any open HTML tags before it does so.

« previous php.notes (#169851) next »