Getting ’ instead of an apostrophe(') in PHP

前端 未结 14 997
慢半拍i
慢半拍i 2020-11-27 02:38

I\'ve tried converting the text to or from utf8, which didn\'t seem to help.

I\'m getting:

\"It’s Getting the Best of Me\"

It sho

14条回答
  •  借酒劲吻你
    2020-11-27 03:31

    Your content is fine; the problem is with the headers the server is sending:

    Connection:Keep-Alive
    Content-Length:502
    Content-Type:text/html
    Date:Thu, 18 Feb 2010 20:45:32 GMT
    Keep-Alive:timeout=1, max=25
    Server:Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.7 with Suhosin-Patch
    X-Powered-By:PHP/5.2.4-2ubuntu5.7
    

    Content-Type should be set to Content-type: text/plain; charset=utf-8, because this page is not HTML and uses the utf-8 encoding. Chromium on Mac guesses ISO-8859-1 and displays the characters you're describing.

    If you are not in control of the site, specify the encoding as UTF-8 to whatever function you use to retrieve the content. I'm not familiar enough with PHP to know how exactly.

提交回复
热议问题