Iai*_*son 0 php redirect if-statement
我试图在PHP写一个if语句,但我不知道如何在一个条件下将用户重定向到另一个URL.我想要做的是:
if $member = $notmember
go here index.php?option=com_jumi&view=application&fileid=6&Itemid=174
else
go here index.php?option=com_jumi&view=application&fileid=6&Itemid=124
Run Code Online (Sandbox Code Playgroud)
我不知道如何重定向到另一个网址?
你可以用header.像这样的东西:
if ($member == $notmember)
header("Location: index.php?option=com_jumi&view=application&fileid=6&Itemid=174");
else
header("Location: index.php?option=com_jumi&view=application&fileid=6&Itemid=124");
Run Code Online (Sandbox Code Playgroud)
如果之后else有更多代码,则应使用 exit() 以防止代码继续执行.
看看PHP官方网站.特别注意以下几点:
请记住,在发送任何实际输出之前,必须通过普通HTML标记,文件中的空行或PHP来调用header().