PHP includes html page issue

after querying mysql db using the code below, I created an html file:

    $myFile = "page.htm";

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

In msql db, text is encoded using utf8_general_ci. But I need to include it in the php webpage as below:

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

keeping in mind that the php webpage uses utf8 encoding in the header:

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

Now, if I write a few letters on db with a serious accent (è à ì) or a quotation mark, and I open page.htm directly, and on db I see that everything looks fine, but when I look at it on php on the page I I see a question mark instead of the ones I originally wanted. What for?! Thanks in advance!

+3
7

, html- HTTP Content-Type, , , PHP (.. ).

<?php
header('Content-Type: text/html; charset=utf8');

, PHP, html , html , :)

():

  • <? php, <? () .
  • include - , , : include 'page.htm';
+5

META . , IDE UTF-8. Dreamweaver CTRL-J, Title/Encoding.

+5

header('Content-Type: text/html; charset=iso-8859-1'); - php include. , . iso-8859-1. , !

+2

, , Php db utf8 ( , ), , db .. ;)

: mysql_select_db ($ database, $connect); mysql_set_charset ('utf8', $connect);// .

+2

, mySQL .

100% utf8_general_ci, mysql_query("SET NAMES utf8;"); : UTF-8.

+1

:

include, php-, php , htm:

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

, , :)

0

Try . Ex mainpage.php:

<?php
 include("php1.php");
?>

<?php
 include("php2.php");
?>enter code here
0

Source: https://habr.com/ru/post/1752727/


All Articles