网页正常,查看源码显示中文全是乱码

来源:百度知道 编辑:UC知道 时间:2024/06/18 16:53:53
我用html+smarty生成的网页,html页面和php程序都是utf8格式的。生成的页面在各个流量器中显示也是正常的,但就是在IE下查看源码,中文全是乱码不知道为什么
我的这些页面都用Notepad++去bom了应该不会有bom了,如果只能这样的话能被搜索引擎搜到吗?比如百度什么的

这个问题涉及到很多问题
如数据库,cutStr等等吧

但是不影响被百度等搜索引擎 收录

给你一个cutStr的代码

function cutStr($string, $length) {
$strcut = '';
$strLength = 0;
if(strlen($string) > $length) {
//将$length换算成实际UTF8格式编码下字符串的长度
for($i = 0; $i < $length; $i++) {
if ( $strLength >= strlen($string) )
break;
//当检测到一个中文字符时
if( ord($string[$strLength]) > 127 )
$strLength += 3;
else
$strLength += 1;
}
return substr($string, 0, $strLength).'...';
} else {
return $string;
}
}