PHP不打印特殊字符

时间:2013-05-05 18:35:43

标签: php utf-8

我正在接收文本文件上传,然后将其打印出来。出于某种原因,特殊字符显示为带有白色复选标记的黑框。我在要打印到屏幕的内容上尝试了htmlentities()和utf8_encode(),但这没有帮助。

以下是我的所有代码:

<?php ini_set("auto_detect_line_endings", true);
header('Content-Type: text/html; charset=utf-8');
?><!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body style="overflow:visible;">
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<button type="submit" name="upload" value="upload">Upload</button>
</form>
<pre>
<?php

if($_POST['upload']) {
//$fileName = 'old.txt';
$fileName = $_FILES['file']['tmp_name'];


    if(file_exists($fileName)) {
        $file = fopen($fileName,'r');
        while(!feof($file)) {
            $name = fgets($file);
            echo(htmlentities($name));
        }
        fclose($file);
    }
}
?>
</pre>
</body>
</html>

此代码适用于我的localhost LAMP服务器,但字符probelm出现在其他人的服务器上。我可以做些什么来显示特殊角色?

0 个答案:

没有答案
相关问题