It's a bit fuzzy for me right now the exact use case we're looking at here. It sort of sounds like what you're asking is something in a link that would tell the target page what is supposed to be output, but that seems too obvious and something I'm pretty sure you already know how to do, so I suspect I need a few more details to understand the question. 🙂
Or is it that you want something to be downloaded as an attachment instead of displayed in the browser? If so, [man]header[/man] would be your friend. There are some examples on that page of how to make the output into a download, so you'd just need some conditional check, maybe via a "download" parameter in the URL?
if(isset($_GET['download'])) {
// set download/attachment headers here
// must be done before any output is sent to the browser
}
// rest of script