我不多说废话。直接贴代码,希望各位老大帮忙解决一下。index.php的主要代码:
$title="PHP is good系统";
$tl->set_file('header');
$tl->n();$tl->set_file('index');
$tl->n();$tl->set_file('footer');
$tl->n();
$tl->p('index');自定义函数:
function set_file
function set_file(
$FileName,
$NewDir=''
){
$this->ThisFile = $FileName.'.'.$this->Ext;
$this->IncList[] = $this->TemplateDir.$this->ThisFile;
if($NewDir!='')
$this->NewDir = $NewDir.'/';
}
function n():
function n(){
$this->FileList[$this->ThisFile] = $this->TemplateDir;
//文件日期(用于对比最新时间更新模板)
$this->FileDate[] = @filemtime($this->TemplateDir.$this->NewDir.$this->ThisFile);
}function p():
function p(
$kind=''
){
if($this->RunType=='Cache'){
echo ($kind=='include_page')?$this->ParsePHP($kind):$this->ParseHtml($kind,'print');
}else{
if($kind){
$kind = ($kind=='include_page')?'include_page':$this->FileList;
echo $this->ParseCode($kind);
}else{
echo $this->ParseCode();
}
}
}
问题如题所示。用本地调试不会出现乱码、上传到国内的服务器也不会。只有上传到国外的就会出现乱码,但是如果直接访问index.htm的时候中文可以正常显示。所以我觉得是index.php里面导入index、header和footer的时候那一部分的方法有问题,或者没有正确解码。但是不知道怎么解决。上面把所有的导入方法都贴出来了。希望有人能帮帮忙。谢谢
$title="PHP is good系统";
$tl->set_file('header');
$tl->n();$tl->set_file('index');
$tl->n();$tl->set_file('footer');
$tl->n();
$tl->p('index');自定义函数:
function set_file
function set_file(
$FileName,
$NewDir=''
){
$this->ThisFile = $FileName.'.'.$this->Ext;
$this->IncList[] = $this->TemplateDir.$this->ThisFile;
if($NewDir!='')
$this->NewDir = $NewDir.'/';
}
function n():
function n(){
$this->FileList[$this->ThisFile] = $this->TemplateDir;
//文件日期(用于对比最新时间更新模板)
$this->FileDate[] = @filemtime($this->TemplateDir.$this->NewDir.$this->ThisFile);
}function p():
function p(
$kind=''
){
if($this->RunType=='Cache'){
echo ($kind=='include_page')?$this->ParsePHP($kind):$this->ParseHtml($kind,'print');
}else{
if($kind){
$kind = ($kind=='include_page')?'include_page':$this->FileList;
echo $this->ParseCode($kind);
}else{
echo $this->ParseCode();
}
}
}
问题如题所示。用本地调试不会出现乱码、上传到国内的服务器也不会。只有上传到国外的就会出现乱码,但是如果直接访问index.htm的时候中文可以正常显示。所以我觉得是index.php里面导入index、header和footer的时候那一部分的方法有问题,或者没有正确解码。但是不知道怎么解决。上面把所有的导入方法都贴出来了。希望有人能帮帮忙。谢谢
<?php//这里是PHP代码?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>标题</title>
</head>
<body>
......
</body>
</html>改为:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php//这里是PHP代码?>标题</title>
</head>
<body>
......
</body>
</html>
2、其次PHP代码前加一句代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php
ini_set('default_charset', 'utf-8'); //或gb2312,随你需//这里是PHP代码?>标题</title>
</head>
<body>
......
</body>
</html>