PHP Include and accents (They show up as �)

后端 未结 5 1562
陌清茗
陌清茗 2020-12-17 23:08

I\'m using PHP include to include a PHP file that has HTML in it. some of the content has french accents and these show up as � on the site. How can this be solved?

相关标签:
5条回答
  • 2020-12-17 23:49

    I had the same issue with a website for a French hotel.

    Changing the charset to "ISO-8859-1" instead of "UTF-8" did the trick.

    Example: < form method="post" name="contact" action="send_mail.php" accept-charset="ISO-8859-1" >

    0 讨论(0)
  • 2020-12-17 23:54

    What is the charset of the HTML page? It sounds like the charset of the PHP file and the HTML within it differ. You might want to check out:

    • http://htmlhelp.com/tools/validator/charset.html.en
    • http://www.w3.org/TR/REC-html40/charset.html
    • https://stackoverflow.com/search?q=html+charset

    For more help, please post some code, specifically the doctype which is being output and any calls to PHP charset functions.

    0 讨论(0)
  • 2020-12-17 23:59

    If switching the charset doesn't fix it, you can use entities. &eacute; for é, &ocirc; for ô and so on

    P.S. 'Il a une erreur avec vôtre email' -> You should say 'Il y a', it's votre not vôtre and email can be translated to 'courriel' :)

    0 讨论(0)
  • 2020-12-17 23:59

    Try using

    <meta http-equiv="Content-Language" content="fr"/>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    0 讨论(0)
  • 2020-12-18 00:08

    That happens if the browser thinks your using another encoding than you actually use.

    try to add the following in your php file before any html is printed:

    header ('Content-type: text/html; charset=utf-8');
    // or
    header ('Content-type: text/html; charset=iso8859-15');
    

    and add

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <!-- or -->
    <meta http-equiv="Content-Type" content="text/html; charset=ISO8859-15" />
    

    between the <head></head> tags

    UPDATE: just saw your update with the file. you need to add header ('Content-type: text/html; charset=utf-8');

    0 讨论(0)
提交回复
热议问题