2

当我访问我的页面时,我得到一个空白显示和以下消息:

“未声明 HTML 文档的字符编码。如果文档包含 US-ASCII 范围之外的字符,则在某些浏览器配置中,文档将呈现乱码。页面的字符编码必须在文档中或在传输协议。”

以下是相关代码:

<?php 
$errors = array();
$missing = array();
//check if the form has been submitted
if (isset($_POST['send'])) 
{
//email processing script
$to = '$_POST['email']';
$subject = 'Your Quote';
$expected = array('email',);
$required = array('email');
$headers .= 'Content-Type: text/plain; charset=utf-8';
require('./includes/processmail.inc.php');
if ($mailSent) {
header('Location: http://www.dailyspiro.com/email.php');
exit;
}
}       
?>

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding"> 
4

2 回答 2

2

在 PHP 代码顶部使用以下 PHP 标头

header('Content-type: text/html; charset=utf-8');

IE。

<?php 
header('Content-type: text/html; charset=utf-8');
$errors = array();
$missing = array();
//check if the form has been submitted
if (isset($_POST['send'])) 
{
//email processing script
$to = '$_POST['email']';
于 2013-04-28T04:37:23.137 回答
-5

尝试使用标准文档类型,而不是使用元标记来声明编码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
于 2013-04-28T04:38:26.630 回答