Home  >  Article  >  php教程  >  php中header跳转使用include包含解决参数丢失问题,headerinclude

php中header跳转使用include包含解决参数丢失问题,headerinclude

WBOY
WBOYOriginal
2016-06-13 09:05:101108browse

php中header跳转使用include包含解决参数丢失问题,headerinclude

有同事反映,最近上线的几款游戏海外注册载入不了样式文件,需要紧急修复。

注册程序统一走单一入口,核心判断是checkip处,只需要在未实名认证的模板程序处做一个game_id的判断即可。因为太过肯定、急于下班的心理,再加上大家催促的紧张,一下子就蒙了,犯了两个错误:一是game_id的判断位置提前了,导致后面的很多变量没有传到目的页面;二是没有理解header跳转和include包含的涵义,直接用了header做跳转。

header跳转后的页面,不能继承上一页的变量等元素,举例说明:

a.php文件

$userEname = "crystal";
$userCname = "程程";
//your code
................................
header("location:b.php");
//your code
..................

如果在b.php文件里引用$userEname,你猜结果是什么?此时的$userEname = null。如果用include包含b.php的话,就能避免$userEname为空的问题了。

以上所述就是本文的全部内容了,希望大家能够喜欢。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn