title: Why does this PHP header() redirect get stuck in an infinite loop?
body: <p>I have this piece of code that is supposed to get the current date, comapre it to a set end date, and redirect if the current date is past the end date. Whenever I set the $promoend to a past date, I get stuck in a redirect loop.</p>
  
  <p>The if() block should only redirect if the promotion has ended and I am not on the closed.php page already.</p>
  
  <pre><code>$currentdate = new DateTime("now");
  $promoend = new DateTime("11/01/2010 00:00:00");
  $promoend = $currentdate-&gt;diff($promoend)-&gt;invert;
  if ($promoend &amp;&amp; !strpos($_SERVER["PHP_SELF"],"closed.php")) {
      header("Location: ".$environment-&gt;root."/closed.php");
  }
  </code></pre>
  
  <p>Any idea why this is caught in a loop?</p>