php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10156 nl2br doesn't ad XHTML slash
Submitted: 2001-04-04 07:13 UTC Modified: 2001-07-04 13:57 UTC
From: kynaston at yahoo dot com Assigned:
Status: Closed Package: Output Control
PHP Version: 4.0.4pl1 OS: Red Hat 7.0 (x86)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 + 18 = ?
Subscribe to this entry?

 
 [2001-04-04 07:13 UTC] kynaston at yahoo dot com
It seems that contrary to the docs, nl2br doesn't replace returns with <br/>, only with <br>.

Give it a try with:
print htmlspecialchars(nl2br("line1 \n line2 \n line3"));

If you're looking for XHTML compliance, use:

function nl2br_xhtml($text) {
	return str_replace("<br>", "<br />", nl2br($text));
}

rgds,

Matt

My config command:
'./configure' '--prefix=/usr' '--with-config-file-path=/etc' '--disable-debug' '--enable-pic' '--enable-shared' '--enable-inline-optimization' '--with-apxs=/usr/sbin/apxs' '--with-exec-dir=/usr/bin' '--with-regex=system' '--with-gettext' '--with-gd' '--with-jpeg-dir=/usr' '--with-png' '--with-zlib' '--with-db2' '--with-db3' '--with-gdbm' '--enable-debugger' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-yp' '--enable-ftp' '--enable-wddx' '--without-mysql' '--without-oracle' '--without-oci8' '--with-xml'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-04 07:23 UTC] derick@php.net
It will be in 4.0.5, the docs are ahead of releases this time.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Oct 31 19:01:24 2020 UTC