[thelist] PHP nl2br - <br> and <br />

**1st Vamp** wes at pmason.karoo.co.uk
Sun Mar 24 18:31:01 CST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: MD5

True. Can't really remember why I typed that (only 5 minutes ago).
Must be getting tired.

<tip value="nl2br and HTML v4.xx compatibility">
In the latest versions of PHP, the function nl2br will output
XHTML/XML compatible br tags (i.e. <br />), if you're using a DTD
earlier than the XHTML v1.x DTD, try using $string =
str_replace("\n","<br>"$string); instread to output HTML (not XHTML)
compatible BR tags, so that the BR tag corresponds with your DTD (and
will also validate if you want it to be validated).
</tip>

- - Vamp

Monday, March 25, 2002, 12:12:27 AM, Joel Canfield wrote:

>>I can't see why the W3 validator shouldn't validate <br /> as
>>HTML 4.01, I know it's XML/XHTML, but isn't the whole point of
>>it for backwards compatibility? If a browser rendering engine
>>will see it as valid, why not the validator?
>>

> That's exactly the point; it's not valid according to the HTML spec, afaik.
> If you want to use XML/XHTML you have to use the correct DTD. Can't be
> backwards compatible unless you're already forward. Or something like that.

> spinhead

-----BEGIN PGP SIGNATURE-----
Version: 2.6

iQINAwUAPJ5vbutR7En81eJTAQF0XA+5AYih2Ap30QvAkWT/n6eGNMldMG8ZGRdV
qdeVN46ICHbPHVU0IRK9BbiQhLf6Mt8m1B0sZoZpf/xEfbT2WL3PhMMns6xW6BZb
Vxj3vfa6kxFzNC/C+0kMt0EMZlyZZbR+EDOVAuHbxXsXtRSHvPc6Ho6FMmYbFFm0
SQGnk4V0tzMwm+imkkQoLB79xogphRSxfVRSi3LV5xU9P7PwJzAOGLXYwielQvQ6
xlpWua5FyYW1lqRPK44cw+T0ju4WK9zBQweIXpSdQecjXqU4NaA7iYJydkMqR9sI
gumLnKVOm2VFF4ua65d+2svho3hWzIAfJtsnT1s4ajNxxP4QuC62G5340FX1kuJ7
4d5/FrGj5OPBcqwVMt7xh9EZW/+OjH+BDZiQtmRV8ilBPZrsyK+3/mFiyfw/MzDK
w9Gbbn+4sqbTEffAun1XNcBn71qUynyduFVGa5XJLElx6S9uxzkdX6XT0bQtdcLR
beEjYK+PpDIWSa5CESq/xKDQrZLBtQdRbRBPtqfZ8YmDiSyc8kSRHo6lNNczavzm
5cHcYK2FkB5b9zBiLsZTz6+cB5ORzL5SCrQCtrdz+TlQElTkeb/3e1a8pEQL9Yhe
NpY8vcfvL8mOy5jU4YpPyYJH0ZGngm5GBUAU/TJnFm3pPUKXXQ1cho79i4vjpnRD
=ONok
-----END PGP SIGNATURE-----




More information about the thelist mailing list