PHP include html page charset problem

2019-05-05 00:31发布

after querying a mysql db using the code below i have generated an html file:

    $myFile = "page.htm";

$fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $row['text']); fclose($fh);

On the msql db the text is encoded using utf8_general_ci. But i need to include it in a php web page as shown below:

 <?include('page.htm');?>

bearing in mind that the php web page uses utf8 charset on the header:

<meta http-equiv="content-type" content="text/html; charset=utf8" />

Now if i write on the db some letters with grave accent (è à ì) or a quote character and i open directly page.htm and on the db i see it all looking ok, but when i view it on the php page i see a question mark � character instead of those I originally wanted. Why?! Thanks in advance!

7条回答
女痞
2楼-- · 2019-05-05 01:33

I solved adding this header('Content-Type: text/html; charset=iso-8859-1'); in the php webpage with the include. I don't know why it works. I never used iso-8859-1 charset. Thanks anyway!

查看更多
登录 后发表回答