在这个事件上去这个网址,否则去这里 [英] On this event go to this url , else go here
问题描述
我正在尝试在php中写一个if语句,但我不确定如何在一个条件下将用户重定向到另一个url。
我想做的是:
I am trying to write an if statment in php but I am not sure how to redirect the user to another url on a condition. What I am trying to do is :
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
我不知道如何重定向到另一个网址?。
I am not sure how to redirect to another url though ?.
推荐答案
您可以使用标题
。这样的事情:
You could use header
. Something like this:
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");
如果在 else
之后,你还有更多代码,你应该使用 exit()
,以防止你的代码继续执行。
If after the else
, you have more code, you should use exit()
in order to prevent of your code to keep executing.
看看在PHP官方网站。特别注意以下几点:
Have a look at the PHP official website. And especially take notice to the following:
请记住,在发送任何实际输出
之前必须调用header(),或者通过普通的HTML标签,文件中的空行或PHP。
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
这篇关于在这个事件上去这个网址,否则去这里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!