【问题标题】:PHP Get MethodsPHP 获取方法
【发布时间】:2019-02-19 17:22:24
【问题描述】:

有可能吗

header("location: ../../index.php?page=account?msg=changesuccess");

所以我想要 2 条消息。 1. 是 page=account 并且在 index.php 中是这样的:

elseif($page == "account"){
    require_once("frontend/pages/accountsettings/account.php");
}
  1. 消息是,一旦我从上面打开 account.php,msg=changesuccess

【问题讨论】:

  • 谢谢,它与“&”一起使用。我没有做那个解析部分。在这个知识点上,我不知道这意味着什么 xD。

标签: php methods get


【解决方案1】:

假设您将$page 设置为

$page = $_GET['page'];

您只需更改 URL 中的查询字符串即可正确添加 msg 参数。

header("location: ../../index.php?page=account&msg=changesuccess");

那么你也可以从$_GET 获得它。由于您使用 require_once 加载 account.php,因此 index.php 中的任何变量也将在 account.php 中可用。

// ...

elseif($page == "account"){
    $message = $_GET['msg'];
    require_once("frontend/pages/accountsettings/account.php");
    //account.php will have access to $message
}

您实际上不需要创建另一个变量,因为 account.php 也可以直接访问 $_GET,但我只是想表明 index.php 中的任何内容都将是 account.php 中的 in scope也是。

【讨论】:

  • 我现在明白了。但是你写的最后一段代码有错误。它就像 $message = $_GET['msg'];
  • 哦,你当然是对的,我的错。以后请随意建议对此类错别字进行编辑。我肯定会接受这样的编辑,我想大多数其他人也会接受。
猜你喜欢
  • 2013-07-08
  • 2020-06-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-09
  • 2013-12-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多