【问题标题】:PHP redirecting not showing content of the page redirected toPHP重定向不显示重定向到的页面内容
【发布时间】:2017-10-25 00:09:04
【问题描述】:

Page1.php代码;

...
header('Location: editt.php?msg=landing&msisdn='.$msisdn);
...

page2.php 代码;

$msisdn = $_GET['msisdn'];
$msg = $_GET['msg'];
echo 'Page 2 Content '.$msisdn;

【问题讨论】:

  • 大概page2.phpeditt.php
  • 很抱歉问了这么明显的问题,但是......如果直接从地址栏加载,页面是否显示正确?
  • 是page2还是editt?!
  • page2 被称为“editt.php”(带有 2 个“t”)?
  • 第2页是editt.php

标签: php redirect


【解决方案1】:

为什么不使用标头作为数据的容器:

header('msg: msgValue');
header('msisdn: msisdnValue');
header('Location: editt.php');

在edit.php中

$headers = apache_request_headers();

foreach ($headers as $header => $value) {
    echo "$header: $value <br />\n";
}

【讨论】:

  • 我还是有同样的问题。我这样做的方式,它适用于其他页面。当我在 page1 上做同样的事情时它不工作
  • 我认为您在某个地方还有其他问题,请提供您的完整代码
【解决方案2】:

您发布的代码有效,可能在您的其余代码中header( )之前有一些html输出,如果有的话,这也可以在一些包含的文件中。

更新:

可以在此处找到有关同一问题的一些有用答案:

php-header-redirect-not-working

【讨论】:

  • 不,没有html输出,我之前只有一个API调用
  • 有一些有用的答案here,可能会有所帮助。
  • 也许显示更多代码会帮助其他人理解问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-26
  • 1970-01-01
  • 2015-05-13
  • 2015-10-22
  • 1970-01-01
相关资源
最近更新 更多