O'Reilly logo

Wicked Cool PHP by Brian Ward, William Steinmetz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

#42: Converting Plaintext into HTML-Ready Markup

One annoying web aspect of programming is that HTML and plaintext aren't compatible, yet they are frequently used interchangeably. People type things into text areas of forms in plaintext, but chances are pretty good you want to display them in HTML.

Here's an example of something that you might find on a form:

Hey folks,
I recently had my brain removed as a part of my therapy. I am fine, and I can now enjoy Pauly Shore movies with my friends.
Sincerely,
Fred

Because there are no <BR /> or <P> tags in the markup for line breaks, it looks like this when pumped back into a web browser as HTML:

Hey folks, I recently had my brain removed as a part of my therapy. I am fine, and I can now enjoy Pauly Shore movies ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required