从 script.php 中打开 file.html

Alb*_*ion 3 php redirect

我想从 Anchor 调用 php 脚本。

文件.html

<body>
    <a href="file.php?id=1">Click</a>
</body>
Run Code Online (Sandbox Code Playgroud)

脚本文件

<?php

    $id = $_GET['id'];

    ... <do some stuff>;

    <when finished doing some stuff reload file.html>;

?>
Run Code Online (Sandbox Code Playgroud)

然后一旦我在 script.php 中的 php 运行,我想重新打开原始文件。我试过 load() 和 loadHTML(),都没有奏效。什么 PHP 函数会加载 file.html?

非常感谢。

der*_*ann 5

您需要将用户重定向到原始页面:

header( 'Location: http://example.com/file.html' );
Run Code Online (Sandbox Code Playgroud)

只需确保在重定向之前不输出任何内容(将数据发送到浏览器)。