Maison  >  Article  >  développement back-end  >  header("location"$url)不能用来if语句中

header("location"$url)不能用来if语句中

WBOY
WBOYoriginal
2016-06-13 11:10:52599parcourir

header("location".$url)不能用于if语句中?
header("location".$url)不能用于if语句中没有生效
一般不生效的情况都是什么呢

php header()
------解决方案--------------------
冒号呢?在哪?
------解决方案--------------------
最下面的
if($mhavelogin==1) {                 header("Location:".$GameLoginUrl);       } else{ ?> 您还没有登陆,请先登陆  } ?>

改成

if($mhavelogin==1) {                 header("Location:".$GameLoginUrl);       } else{ echo '您还没有登陆,请先登陆';}

具体的原因你百度找一下关于header函数使用时要注意的地方吧
------解决方案--------------------
编写PHP代码 希望你有些地方自己严格要求自己 

header之前不能有输出 

有的UTF8格式的前面有BOM也不行

还有就是,跳转可以js实现

echo "<script>window.location='$url';</script>";
------解决方案--------------------
把header("Content-type: text/html; charset=utf-8"); 挪到else,都跳转了,这个有啥用?
------解决方案--------------------
引用:
引用:把header("Content-type: text/html; charset=utf-8"); 挪到else,都跳转了,这个有啥用?
这是一个登录接口,想点击登陆按钮直接跳转


我是说你跳转就不用再输出其他header了
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn