在用PHP做东西的时候发现了一个问题,可以简单的归结为乱码的问题,但是这个问题不是函数本身造成的。来看看罪魁祸首是谁。
嫌疑人:base64_encode 和 base64_decode
罪行:我写了一个跳转和提示函数,接收提示信息后跳转到指定的页面,但是跳转提示时汉字乱码。
跳转模版代码如下:
<br /><meta charset="utf-8"><meta name="author" content="王健 [email protected]" /><br /><title>跳转提示</title><br /><style type="text/css"><br />*{ padding: 0; margin: 0; }<br />body{ background: #fff; font-family: '微软雅黑'; color: #333; font-size: 16px; text-align:center; }<br />.system-message{ width:600px; margin:150px auto 0 auto; background:#f8f8f8; border:1px solid #ccc;-webkit-border-radius: 8px;-moz-border-radius: 8px;border-radius: 8px;-webkit-box-shadow: #666 0px 0px 10px;-moz-box-shadow: #666 0px 0px 10px;box-shadow: #666 0px 0px 10px;}<br />.system-message h1{ font-size:30px; font-weight:normal; height:100px; line-height:100px; color:#c60;}<br />.system-message .jump{ padding: 40px 0;}<br />.system-message .jump a{ color: #333;}<br />.system-message .success,.system-message .error{ height:60px; line-height:70px; font-size: 18px; color:#900;}<br />.system-message .detail{ font-size: 12px; line-height: 20px; margin-top: 12px; display:none}<br /></style><br /><br /><body><br /> <div class="system-message"><br /> <br /> <h1>:) 恭喜!</h1><br /> <p class="success"></p><br /> <br /> <h1>:( 出错了!</h1><br /> <p class="error"></p><br /> <br /> <p class="detail"></p><br /> <p class="jump">系统将在 <b id="wait"></b> 后跳转,可直接 ">点此跳转</p><br /> <br />
<script type=”text/javascript”>
(function(){
var wait = document.getElementById(‘wait’),href = document.getElementById(‘href’).href;
var interval = setInterval(function(){
var time = –wait.innerHTML;
if(time <= 0) {
location.href = href;
clearInterval(interval);
};
}, 1000);
})();
</script>