note 98230 added to function.nl2br

From: Date: Thu, 03 Jun 2010 06:59:14 +0000
Subject: note 98230 added to function.nl2br
Groups: php.notes 
Request: Send a blank email to php-notes+get-169839@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 173.75.242.221 ---- Manual Page -- http://www.php.net/manual/en/function.nl2br.php Edit -- https://master.php.net/note/edit/98230 Del: integrated -- https://master.php.net/note/delete/98230/integrated Del: useless -- https://master.php.net/note/delete/98230/useless Del: bad code -- https://master.php.net/note/delete/98230/bad+code Del: spam -- https://master.php.net/note/delete/98230/spam Del: non-english -- https://master.php.net/note/delete/98230/non-english Del: in docs -- https://master.php.net/note/delete/98230/in+docs Del: other reasons-- https://master.php.net/note/delete/98230 Reject -- https://master.php.net/note/reject/98230 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169839) next »