Echoed apostrophes suddenly printing as character codes

Discussion in 'PHP' started by Darden12, Jul 17, 2011.

  1. #1
    I've used PHP for a year and have never encountered this problem till now:

    When I echo the $Caption string that I created in my script as follows...

    
    $Caption="<div style='line-height:130%;margin:0px 0px 10px 0px;font-family:verdana;font-size:12px;color:".$col."'>".$Caption."</div>";
    PHP:
    the text that the $Caption string contains is echoed, but it is not formatted by the div css information.

    When I check the source, I see that the apostrophes have been rendeded as code, as follows....

    <div style=&#39;line-height:130%;margin:0px 0px 10px 0px;font-family:verdana;font-size:12px;color:pink&#39;>
    HTML:
    Can someone tell me why the apostrophes are changing into html code like that and how to prevent them from doing so? I have tried every php function that I could think of that has anything to do with encoding and decoding special characters and entities, and so far, no luck.


    Thanks,
    Brian
     
    Darden12, Jul 17, 2011 IP
  2. Darden12

    Darden12 Well-Known Member

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #2
    Problem solved. I found that I was subjecting the entire output to a character replacement routine that should have been reserved for selected bits of data earlier on. Sorry!
     
    Darden12, Jul 17, 2011 IP