Text in html file is displayed but html tags are being ignored

138 views Asked by At

I have a file test.php containing, this:

<HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php include('text.html'); ?>
</body>
</html>

The included file contains a html formated text with various html tags. When executing test.php, the included text is displaid but the html tags are not formating the output but are visible like in a source.Also the utf-8 special characters are not displaid properly

Exemple: �h3> ( 1880, Bucure_ti - 1970, Bucure_ti )<�/h3> <�P>

If I do not use include but I am simply pasting the content of the included file directly into the source code, the output is fine. I also tried to use the below code I found on this site, instead of include, but the result was the same:

<?php  

$f = fopen("bio.php", "r");

// Read line by line until end of file
while(!feof($f)) { 
    echo fgets($f) . "<br />";
}

fclose($f);
?>

What is wrong ?``
1

There are 1 answers

0
Mooseman On BEST ANSWER

text.html and/or test.php are/is not encoded in UTF-8 as your meta tag is claiming. Encode them both in UTF-8. If you're still experiencing issues, encode them UTF-8 w/o BOM. (Byte-Order Mark)