php strftime French characters

前端 未结 9 1471
眼角桃花
眼角桃花 2020-12-08 10:08

I\'m working on a site where the user can switch between English and French. To output the date of posts.

If the user chooses French I use:

setlocale         


        
9条回答
  •  青春惊慌失措
    2020-12-08 10:48

    The Content-Type header needs to set the code page to UTF-8.

    header('Content-Type: text/html; charset=UTF-8');
    

    Since you can't change the header once you've output anything to the page with echo or print make sure you set it early in the page.

    The ASCII code page is fully contained in UTF-8 not vice-versa.

    Replace the UTF-8 header with the ASCII one and you'll see what happens when the characters aren't included in the current code page.

    
    

提交回复
热议问题