SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist sp0om's Avatar
    Join Date
    Feb 2004
    Location
    MN
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validating forum forms

    How can I make a form recognize when I make a line break in a the form.

    Like I did just now. I made a line break in this posting form and it now shows up as a line break. Is there some PHP function that will recognize these line breaks and display them properly?

  2. #2
    SitePoint Evangelist Waffles's Avatar
    Join Date
    Nov 2005
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm a little unsure what you mean but try using nl2br($string) on the output.

    nl2br -- Inserts HTML line breaks before all newlines in a string

  3. #3
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sp0om
    How can I make a form recognize when I make a line break in a the form.

    Like I did just now. I made a line break in this posting form and it now shows up as a line break. Is there some PHP function that will recognize these line breaks and display them properly?
    HTML ignores whitespace. When you output a string containing linebreaks it's not going to have linebreaks on the screen, as they're represented by an HTML tag, <br>, not \n. Use nl2br() as Waffles pointed out to do the conversion for you or do a string replacement.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •