脚本完成后,PHP文件将关闭浏览器。需要它显示“下载完成”消息吗

脚本完成后,PHP文件将关闭浏览器。需要它显示“下载完成”消息吗,php,browser,Php,Browser,我有一个php脚本,它引用了另外两个php脚本。这三个脚本如下: 母版页: <?php header("Content-disposition: attachment; filename=huge_document." header("Content-type: application/pdf"); $FullName = $_GET["FullName"]; global $FullName; Include("Code.php")

我有一个php脚本,它引用了另外两个php脚本。这三个脚本如下:

母版页:

    <?php
    header("Content-disposition: attachment;
    filename=huge_document."
    header("Content-type: application/pdf");
    $FullName = $_GET["FullName"];
    global $FullName;
    Include("Code.php");
    Include ("GetPDFfromServer.php");
    echo ("Download Complete");
    ?>
Code.php:

<?php
require_once ("fpdf17/fpdf.php");
require_once ('FPDI-1.5.2/fpdi.php');
$pdf =& new FPDI();
$pdf->AddPage();
$pdf->setSourceFile("Secret.pdf");
// import page 1
$tplIdx = $pdf->importPage(1);
//use the imported page and place it at point 0,0; calculate width and height
//automatically and adjust the page size to the size of the imported page
$pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);
// now write some text above the imported page
$pdf->SetFont('Arial', '', '36');
$pdf->SetTextColor(0,0,0);
//set position in pdf document
$pdf->SetXY(195, 240);
//$pdf->Write(0, '|');
$pdf->SetXY(0,240);
$pdf->SetMargins(0,"",0);
//force the browser to download the output
$pdf->Cell(0,0,$FullName,0,0,"C",false,"");
//first parameter defines the line height

$pdf->Output('temp/Secret.pdf', "F");
//return;
?>
GetPDFfromServer.php:

<?php

//header("Content-disposition: attachment; filename=huge_document.pdf");
//header("Content-type: application/pdf");
readfile("temp/NIA_SM_Policy_Digital-CertificateNEW.pdf");
Echo("Download Complete");
//return;
?>
当我加载母版页时,例如:www.example/MasterPage.php?FullName=Mark%20Francis它成功地完成了所有功能创建了一个个性化的.pdf,将其下载到服务器,然后将其下载到浏览器。然而,我想显示一条消息,说下载完成或类似的东西,但浏览器选项卡立即关闭

任何帮助都将不胜感激


谢谢

我的重定向更新代码:

<!DOCTYPE html>
<html>
<body>

<?php
readfile("temp/Secret.pdf");
?>

<script type="text/javascript">
window.location = "http://www.google.com/"
</script>


</body>
</html>

用PHP不能做到这一点。readfile函数将文件写入缓冲区。不能在同一页面中为用户添加任何其他输出。你需要用JS重定向,或者下载只是一个单独的链接。好的,我明白了。非常感谢你的帮助!写下这个作为答案,如果你愿意,我可以接受!