消息关闭
    暂无新消息!

php 二进制unpack、汉字转码2

问题作者 : Cleve2017-08-29发布
header("Content-Type: text/html;charset=utf-8");
$key=$_GET['key'];
$market=$_GET['market'];
$redisStr='127.0.0.1';
$redisPort=6379;
$pageNum=2000;
$res=array();$res['result'] = "0";$res['msg'] = "";$res['data'] = array();
$result = array();

if (strcasecmp($key,"jgt")==0)
{
    try {$redis = new Redis();$redis->connect($redisStr,$redisPort);} catch (Exception $e){echo "redis failure";}
    list($m,$page)=explode("_",$market,2);
    if ($redis->exists($m))
    {
        $num=$redis->lSize($m);
        if ($page%ceil($num/$pageNum)==0) $page=ceil($num/$pageNum); else $page=$page%ceil($num/$pageNum);
        $listData= $redis->lRange($m,($page-1)*$pageNum,($page-1)*$pageNum+($pageNum-1));
        foreach ($listData as $label)
        {
            $data=$redis->hGetAll("$label");//hKeys;hVals;hGetAll;?????//
            $d=base64_encode(serialize($data));
            print_r($d);//可准确输出
            array_push($result,handle($s));//------------------------------------------------------------------------------------不能执行
        }
        $res['result'] = "1";
    }else
    {
    }
    echo '<br />';
    echo json_encode($res);
}
else
{
    $res['msg'] = "Unauthorized access!";
    echo '<br />';
    echo json_encode($res);
}

function handle($s){
    $data = unserialize(base64_decode($s));
    $format = 'itime/flast/fop/fhi';
    $format = 'it/fl/fo/fh/flo/fcl/fv/fam/fop/fb/fs/ftotlVo';
    $data['k1'] = unpack($format, $data['k1']);
    $data['name'] = mb_convert_encoding($data['name'], 'UTF8', 'GBK');
    return $data;
}


用了另一帖子版主的部分代码,但是标注的那一句还是执行有问题,请帮忙

3个回答

︿ 1
502 是网关错,与程序本身无关,程序崩溃只可能引发 500 错
换个 web 服务器再试