PHP unlink() breaks file_exists, header, and echo functions?
<p>I have the following code:</p>

<pre><code>$tmpfile = $tempDirectory . $file ;

if (file_exists($tmpfile)) {

   header('Location: &lt;some location&gt;');

}
</code></pre>

<p>It works flawlessly, the file exists, I get redirected to my new page.</p>

<p>So, now I know that the file exists and works. So, I go into FTP, ensure the file is there.</p>

<p>Then I run this code:</p>

<pre><code>$tmpfile = $tempDirectory . $file ;

if (file_exists($tmpfile)) {

   unlink($tmpfile);
   header('Location: &lt;some location&gt;');

}
</code></pre>

<p>Redirect stops working. PHP outputs nothing. The file gets deleted from the FTP directory. But the redirect completely fails.</p>

<p>If I put an <code>echo</code> inside the if statement when there is an unlink present (before or after any other line of code in the if statement, it outputs nothing.</p>

<p>There isn't an unlink error, and the file is clearly deleted when I check FTP, so what is going on here?</p>

<p>It gets deleted when the code is run, so it's obviously not a permission issue. It wouldn't be able to delete the file if it didn't have permissions to do so.</p>

<p>Any help is appreciated. Thanks!</p>
