php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44795 nl2br should have option for generating HTML instead of XHTML
Submitted: 2008-04-22 01:09 UTC Modified: 2008-04-22 01:48 UTC
From: mmiikkee13 at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
 [2008-04-22 01:09 UTC] mmiikkee13 at gmail dot com
Description:
------------
nl2br should include an optional argument to make it generate HTML instead of XHTML. Not every site uses XHTML, and PHP doesn't usually seem like an XHTML-specific language to me - heck, it can even echo out C code if you were that crazy. (No offense to anyone who's actually tried that.)

XHTML could still be the default, but the function should be changed to something like nl2br($text, $xhtml=FALSE).

While <br /> may only generate a warning in the W3C validator, it recommends only using it in XHTML documents, not HTML. Besides that, people view pages with browsers, not hyperactive validators.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-22 01:48 UTC] felipe@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Duplicated.

Bug #34381
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Feb 05 10:00:01 2026 UTC