【问题标题】:PHP page not redrawing after redirect to new received from get_file_contentsPHP 页面在重定向到从 get_file_contents 接收到的新内容后不重绘
【发布时间】:2022-11-29 14:06:45
【问题描述】:

我的代码:-

$host = "https://example.org/get.php?";
$newurl = file_get_contents($url);
$newurl = substr($newurl,stripos($newurl,"who"));
$newurl = substr($newurl,0,stripos($newurl,"</"));
// newurl string starts with "who" and ends with "</"
//var_dump($host.$newurl)."<br>";  //shows correct request string
header("Location: " . $host.$newurl);
exit(); 

新窗口在地址栏中显示正确的 url 请求但未重绘 除了单个“1”字符外,页面源是空白的。 在按下重新提交按钮时,页面被正确绘制。 非常感谢任何帮助。

史蒂夫

【问题讨论】:

  • file_get_contents($url)中的$url变量没有定义?
  • 如果您在header 之前输出一些内容,那么您会使标头无效

标签: php html


【解决方案1】:

您可以将 file_get_contents($url); 更改为 $host 因为它不是正确的源 url

【讨论】:

    猜你喜欢
    • 2016-11-18
    • 2017-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-10
    • 2011-11-09
    • 2013-06-12
    • 2020-02-02
    相关资源
    最近更新 更多