Results 1 to 7 of 7

Thread: displaying messages...

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    32

    Exclamation displaying messages...

    Just as the function nl2br() , is there any function to handle the conversion of tab to html counterpart? (Or performs both).

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: displaying messages...

    check out htmlentities() but i think you would have to manually convert tabs to four &nbsp;'s.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: displaying messages...

    Tabs don't exist in HTML. If you need to indent just one line, use four &nbsp;s. If it's an entire paragraph, you might want to surround it in <blockquote>

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: displaying messages...

    UAs ignore whitespace by default, unless you explicity say otherwise (using the CSS white-space property, or the <pre> tag which does that by default). Using non breaking spaces (&nbsp;) is not a good idea unless they really shouldn't be non-breaking spaces, i.e. a section of text should be displayed on one line.

    If you need to indent text, use the text-indent property (for the first line of a paragraph) or the margin property (for the whole paragraph). You're using <p> tags? Good.

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    32

    Arrow Re: displaying messages...

    Whts the exact procedure for displaying messages stored in a database?. Curently I am able to do this, But I need to display thr message exactly as enterd by the user keeping newline and spaces in place. With nl2br I have managed to handle newlines but the tab and white spaces are still a problem!!!.

    Any shortcuts, other than checking for whitespaces manually?

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: displaying messages...

    Use white-space:pre like I suggested.

    HTML Code:
    <p class="message">
      <?=$message?>
    </p>
    Code:
    .message {
      white-space: pre;
    }

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    32

    Resolved Re: displaying messages...

    Thanks for the reply.

Posting Permissions

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



Click Here to Expand Forum to Full Width