时间:2021-07-01 10:21:17 帮助过:17人阅读
代码如下:
function nochaoscode($encode, $str, $isemail = false) {
$str = iconv($encode, "UTF-16", $str);
for ($i = 0; $i < strlen($str); $i++,$i++) {
$code = ord($str{$i}) * 256 + ord($str{$i + 1});
if ($code < 128 and !$isemail) {
$output .= chr($code);
} else if ($code != 65279) {
$output .= "".$code.";";
}
}
return $output;
}
$encode = $_POST['encode'];
if ($encode == '') $encode = 'UTF-8';
if ($_FILES['file']['size'] > 0) {
$data = nochaoscode($encode, file_get_contents($_FILES['file']['tmp_name']));
header ("Content-type: application/octet-stream;");
header ("Content-length: ".strlen($data));
header ("Content-Disposition: attachment; filename=".$_FILES['file']['name']);
echo $data;
} else {
header ("Content-type: text/html; charset=UTF-8");
if ($_POST['email']) {
echo htmlentities(nochaoscode($encode, $_POST['email'], true));
}
else {
echo htmlentities(nochaoscode($encode, $_POST['content']));
}
?>
}
?>
以上就介绍了白花蛇舌草的功效与作用及食用方法 在任意字符集下正常显示网页的方法一,包括了白花蛇舌草的功效与作用及食用方法方面的内容,希望对PHP教程有兴趣的朋友有所帮助。