2017-10-13 103 views

回答

1

如果您将$ s2字符串编码为UTF-8,它应该可以工作。

你可以做到这一点与PHP函数utf8_encode(string)

<?php 
$s2 = file_get_contents("s2.txt"); 
?> 
<div id="slogan"> 
<em>asd</em> 
<strong><?php echo utf8_encode($s2); ?></strong> 
<span>dsa</span> 
</div> 

这应该可以解决它。

+0

您也可以编码的file_get_contents()来代替,这是否为你更好。 – MadsBinger

0

你可以试试下面的代码片段:

function file_get_contents_utf8($fn) { 
    $content = file_get_contents($fn); 
     return mb_convert_encoding($content, 'UTF-8', 
      mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true)); 
} 

$s2 = file_get_contents_utf8("s2.txt"); 

这串编码为UTF8