首页 > 开发 > PHP > 正文

PHP base64编码后解码乱码的解决办法

2024-05-04 22:20:38
字体:
来源:转载
供稿:网友

在用PHP做东西的时候发现了一个问题,可以简单的归结为乱码的问题,但是这个问题不是函数本身造成的。来看看罪魁祸首是谁。

嫌疑人:base64_encode 和 base64_decode

罪行:我写了一个跳转和提示函数,接收提示信息后跳转到指定的页面,但是跳转提示时汉字乱码。

跳转模版代码如下:
代码如下:
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="author" content="王健 wj@yurendu.com" />
<title>跳转提示</title>
<style type="text/css">
*{ padding: 0; margin: 0; }
body{ background: #fff; font-family: '微软雅黑'; color: #333; font-size: 16px;  text-align:center; }
.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;}
.system-message h1{ font-size:30px; font-weight:normal; height:100px; line-height:100px; color:#c60;}
.system-message .jump{ padding: 40px 0;}
.system-message .jump a{ color: #333;}
.system-message .success,.system-message .error{ height:60px; line-height:70px; font-size: 18px; color:#900;}
.system-message .detail{ font-size: 12px; line-height: 20px; margin-top: 12px; display:none}
</style>
</head>
<body>
    <div class="system-message">
        <?php if( $_GET['success'] ){?>
            <h1>:)   恭喜!</h1>
            <p class="success"><?php echo base64_decode($_GET['message']); ?></p>
        <?php }else{?>
            <h1>:(   出错了!</h1>
            <p class="error"><?php echo base64_decode($_GET['message']); ?></p>
        <?php }?>
        <p class="detail"></p>
        <p class="jump">系统将在 <b id="wait"><?php echo $_GET['time']; ?></b> 后跳转,可直接 <a id="href" href="<?php echo base64_decode($_GET['url']); ?>">点此跳转</a></p>
       
    </div>
<script type="text/javascript">
(function(){
var wait = document.getElementById('wait'),href = document.getElementById('href').href;
var interval = setInterval(function(){

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表