【发布时间】:2019-11-30 02:08:49
【问题描述】:
我有两个文件。一种是header.php 和index.php。我不明白 $_GET['a'] 数据是如何从 header.php 文件传递到路由系统的 index.php 的。
我已经尝试找到 $_GET['a'] 从 header.php 到 index.php 的传递方法
图片是header.php文件的一部分
/*index.php*/
include("sources/header.php");
$a = protect($_GET['a']);
switch ($a) {
case "account": include("sources/account.php"); break;
case "login": include("sources/login.php"); break;
case "register": include("sources/register.php"); break;
case "track": include("sources/track.php"); break;
case "testimonials": include("sources/testimonials.php"); break;
case "affiliate": include("sources/affiliate.php"); break;
case "contact": include("sources/contact.php"); break;
case "about": include("sources/about.php"); break;
case "faq": include("sources/faq.php"); break;
case "page": include("sources/page.php"); break;
case "exchange": include("sources/exchange.php"); break;
case "search": include("sources/search.php"); break;
case "password": include("sources/password.php"); break;
case "email-verify": include("sources/email-verify.php"); break;
case "logout":
unset($_SESSION['bit_uid']);
unset($_COOKIE['bitexchanger_uid']);
setcookie("bitexchanger_uid", "", time() - (86400 * 30), '/'); // 86400 = 1 day
session_unset();
session_destroy();
header("Location: $settings[url]");
break;
default: include("sources/homepage.php");
}
我希望知道 $_GET['a'] 是如何从 header.php 传递到 index.php
【问题讨论】:
-
没有任何东西从
header.php传递到index.php。$_GET(如 $_SESSION 和 $COOKIE)在全球范围内可用。 -
$_GET是 superglobal。这意味着它在整个脚本的所有范围内都可用。 -
从屏幕截图看来,您正在将一些基本 URL (
$settings[url]) 与链接关键字testimonials、affiliate等组合在一起。所以可能涉及到一些 URL 重写 (. htaccess),它将那些传入的请求从/foo重写为somescript.php?a=foo -
那么 $_GET['a'] 的值是多少???并且这个值被插入到 $_GET['a']?? @kerbholz
-
$_GET['a']是一个 URL 参数。 php.net/manual/en/reserved.variables.get.php。在您的 URL 中设置,或者在protect()函数中的某个位置设置。或者,正如@misorude 所说,在服务器重写中
标签: php