SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question htmlentities() problems

    Hi I'm using htmlentities() to display different language characters correctly but this is now returning <br> tags as <br> in the text instead of putting an actual break in the text. Does anyone know a way to fix this?

    thanks for any help in advance with this.

  2. #2
    Made with a Mac! philm's Avatar
    Join Date
    Sep 2001
    Location
    Portsmouth, UK
    Posts
    735
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Thanks for the super quick response. I've had a look at the link you posted. Does this mean that for every section I want to display I'll have to use the following to get it to display correctly
    PHP Code:
    <?php
    $orig 
    "I'll \"walk\" the <b>dog</b> now";

    $a htmlentities($orig);

    $b html_entity_decode($a);
    ?>

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You shouldn't add html to the text until after you have run htmlentities() on the text.

  5. #5
    SitePoint Enthusiast the-webber's Avatar
    Join Date
    Mar 2009
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use htmlentities($html) to process/store user input...then when you use late display that input use
    html_entity_decode()
    Last edited by the-webber; Apr 13, 2009 at 08:48. Reason: spelling

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps you should just change the encoding of the page instead?


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
  •