改写一个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的时候不执行任何操作

 <?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/"); 
    }
}
?>