萌新项目人 2018-01-19 13:06 采纳率: 100%
浏览 1338
已采纳

改写一个php判断跳转代码


 <?php
if(!isset($_SESSION['authcode'])) {
    $query=file_get_contents('http://www.xxxx.com/api.php?url='']);
    if($query=json_decode($query,true)) {
        if($query['code']==1)$_SESSION['authcode']=true;
        else exit('<h3>'.$query['msg'].'</h3>');
    }
}
?>

这个http://www.xxxx.com/api.php?url='',运行起来会返回0或者1,希望实现的功能是:
当数值是0的时候,自动跳转到www.xxxx.com,当数值是1的时候不执行任何操作

  • 写回答

1条回答 默认 最新

  • hujiasuta 2018-01-19 15:18
    关注
     <?php
    if(!isset($_SESSION['authcode'])) {
        $query=file_get_contents('http://www.xxxx.com/api.php?url='']);
        if($query=json_decode($query,true)) {
            if($query['code']==1)$_SESSION['authcode']=true;
            //else exit('<h3>'.$query['msg'].'</h3>');
                    if ($query['msg'] == 0) header("Location: http://www.xxxx.com/"); 
        }
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?