php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #8390 nl2br generates bad tag
Submitted: 2000-12-23 18:49 UTC Modified: 2000-12-27 20:03 UTC
From: anil at recoil dot org Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.4 OS: OpenBSD
Private report: No CVE-ID: None
 [2000-12-23 18:49 UTC] anil at recoil dot org
Right now, it's impossible to generate valid XHTML by
using the nl2br() command, as it outputs a <br> tag.

It would be nice to change this to output a <br />
tag instead, which is fully backward compatible afaik,
and also valid XML (and hence XHTML).

Here's an extremely complicated patch that should hopefully accomplish this :-)

--- ext/standard/string.c.orig  Sat Dec 23 23:39:06 2000
+++ ext/standard/string.c       Sat Dec 23 23:40:48 2000
@@ -2304,7 +2304,7 @@ PHP_FUNCTION(nl2br)

        convert_to_string_ex(str);

-       php_char_to_str((*str)->value.str.val,(*str)->value.str.len,'\n',"<br>\n",5,return_value);
+       php_char_to_str((*str)->value.str.val,(*str)->value.str.len,'\n',"<br />\n",7,return_value);
 }
 /* }}} */


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-27 20:03 UTC] jon@php.net
Patch committed.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 17 12:00:02 2026 UTC