Initial Outline

I am using php to write a custom file serving tool for a project i am working on. The tool works well so far, but i have bumped into an odd situation when serving php files.

My initial file, server.php is designed to take a file request and serve the file with correct headers and cache controls etc.

Server.php uses file commands to get the contents of flat files like images and serve them echo print style.

Server.php currently uses include (with output buffering) to get the contents of php files to serve. This works well until the including file contains a die command.

I have experimented using return, instead of die to terminate the process. But it fails to perform the job of die if the included file, includes further files.

---

So in a nutshell, i have got one PHP file "server.php", this includes another php file. I want to get its processed output as if it was an independent flat file. I do not care about the variables being moved into the global scope, I just want the output. Any ideas?

Thanks Guys

---

**EDIT**

server.php

```
<?php
echo 'File start'."<br>\n";
        ob_start();
        include("file.php");
echo    ob_get_clean();
echo 'File end'."<br>\n";
?>

```

file.php

```
<?php
echo 'I am expecting to get this data.'."<br>\n";
die;
echo 'I am not expecting to get this data.'."<br>\n";
?>

```

I hoping to get a result that roughly looks like.  

File start  

I am expecting to get this data.  

File end  

What i get is a result that looks like.  

File start  

I am expecting to get this data.  

If i use a return instead of a die, i get the expected result. But that dosnt stop people using die and breaking my program. Hopefully my edit better explains the problem. Cheers again guys.