如何存在标题位置时如何创建回显

I want to display an echo when a file is deleted. For deleting files in a folder i use this loop:

if (isset($_GET['delete'])) {
    // if is directory -> remove dir
    if(is_dir($_GET['delete'])){
        removeDirectory($_GET['delete']);
    }
    // else (must be a file) -> unlink file
    else {
        unlink($_GET['delete']);
    }

    echo 'file successful deleted!'; // this echo is lost...
    // back to dir
    $dir = dirname(($_GET['delete']));
    header ("Location: ".'?dir='.$dir);
    die();
}

Because of the header location, the echo will not be displayed. Thats a pitty. Is there a way i still can show an echo, even when there is a header location after it?

If you want to show some message to user and then redirect in that case use javascript to alert message and redirect

<?php
 echo("<script>alert('file successful deleted!')</script>");
 echo("<script>window.location = 'home.php';</script>");
?>

There is no point setting message with echo when you do redirect and no one will see that message. Instead of immediately redirect use some time for redirect, like this:

  $dir = dirname(($_GET['delete']));
 header( "refresh:5;url=?dir=".$dir ); 
 echo 'file successful deleted!';
  die();