通过php中的json_encode重定向

时间:2017-03-10 18:10:45

标签: php json redirect

if ($this->register($email, $register_status))
                    {
                        $this->sendConfirmationEmail($email);
                        echo json_encode(array("message" => $this->error = $this->l('Your email was registered. Thank You!'),"code" => 1));
                        die();
                    }

这是我的代码,我想在执行此代码后重定向页面

1 个答案:

答案 0 :(得分:0)

只需使用标题(“Location:your_page.php”);在die()之前;

if ($this->register($email, $register_status))
     {
$this->sendConfirmationEmail($email);
echo json_encode(array("message" => $this->error = $this->l('Your email was registered. Thank You!'),"code" => 1));
header("Location: your_page.php");
die();
                        }

如果错误

添加拳头线toppage

    <?php 
ob_start();
    if ($this->register($email, $register_status))
         {
    $this->sendConfirmationEmail($email);
    echo json_encode(array("message" => $this->error = $this->l('Your email was registered. Thank You!'),"code" => 1));
    header("Location: your_page.php");
    die();
                            }?>