为了账号安全,请及时绑定邮箱和手机立即绑定

IF语句返回不正确的功能

IF语句返回不正确的功能

PHP
哔哔one 2021-05-03 08:04:44
URL的哈希值在上一页的Cookie中设置,然后重定向到登录页面。如果cookie的值为null或具有值,则结果仍为“ else”。$shareURL = $_COOKIE["redirect"];if ( is_user_logged_in() ) {  if (is_null($shareURL)) {         function Redirect($url, $permanent = false){        header('Location: ' . $url, true, $permanent ? 301 : 302);        exit();      }        header('Location: /dashboard');  }else{        function Redirect($url, $permanent = false){        header('Location: ' . $url, true, $permanent ? 301 : 302);        exit();  }        Redirect('/120x220x90', false);     }     }else{    }
查看完整描述

2 回答

?
慕无忌1623718

TA贡献1744条经验 获得超4个赞

您可能不想创建两个功能相同的功能。您可以考虑修改与以下脚本类似的代码,它可以正常工作:


function Redirect($url, $permanent = false)

{

    header('Location: ' . $url, true, $permanent ? 301 : 302);

    exit();

}


$shareURL = $_COOKIE["redirect"];

if (is_user_logged_in()) {

    if (is_null($shareURL)) {

        Redirect('/dashboard', false);

    } else {

        Redirect('/120x220x90', false);

    }

} else {


}


查看完整回答
反对 回复 2021-05-28
  • 2 回答
  • 0 关注
  • 132 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信