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

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


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

ereg_replace for a simple character/string replacement? Yikes!
For speed and simplicity, str_replace (replace \n with <br> for HTML
4.xx compat) will do the trick and with less slow down.

On another note:
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?

- - Vamp

Sunday, March 24, 2002, 4:56:35 PM, s t e f wrote:

> [[ Donald Noble -- 15:43 24/03/02 +0000 ]]
>> >From the PHP manual:
>>"Starting with PHP 4.0.5, nl2br() is now XHTML compliant."
>>
>>What about people who are still using HTML4.01 ??? is there some way to
>>make this function return just <br>, as this is now stopping a lot of my
>>pages validating. :(

> If I were you I'd ereg_replace directly the line breaks. Yeah I know it's
> kind of exactly what you wanted to avoid, yet I don't see any other solution.

> HTH
> stef

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

iQIMAwUAPJ5r6utR7En81eJTAQFsCw+1Fuci5ttko0RGAD2a0ol72ji/xlCkpv/2
dFnaJ3GNdUuUHRvDS/oAdyJoiiXIYsU4zrerW0Ig6JPsOy8omIrVrCbHV+dPeg2U
CQQKBs3fKzZ9GbOr81DhCmQ+1mlDiolypBG5tLSLOMBocmD7Ja0tyeWqHNGjAWGq
c/yhiR27IK9P2lJfjWCKzlwDec+2Tzc+8oJEcz+yjH2B0WAMqh8pDu3t9zsLeCTF
+Xz5xYV9Tvs2vw6Vkg1H0L2gKZTQNBiud2PUpvl1wAXoPrRdLJAHp/z9SZJ/YXGK
EafS8BZQGgfXMMTKzP9Z88XtHIKHVM62mlap62A8xxTcV4dZu6i9ROSTlLq1PSHC
rKaFKW87AqOT9ApnvsO/cicmHkBWofmdugsR5nPSo7iMKF9SZAwVUxCZQ2GXDqWg
7fhLacGS1Uaoi+kLxBqw6doJ+8X1w9JiW6YuA5SETB2Q4pyQzS7Ig7qwSkGrYEXe
9ZZRcRbJNKk1Ull7h7iOYhUbMQj/5NIHgAMIe7oTbk+oNdAENvLZtPHiBcZLhiET
Rwy5aE5nfuxoC9KnFYyK77Udei7j8P3f81YuC0vEOb2X+ZVGvqVreONVXnKyMSxD
U+v37hSbm76zH62Ir9xkQPcIChy6COP7/RG9IhrvsQUF/DlldyYDm596hUGjvfE=
=ANXK
-----END PGP SIGNATURE-----




More information about the thelist mailing list