title: How to use "poor man's cron" with PHP?
body: <p>I'm trying to implement a "poor man's cron" to run my PHP script only every 10 minutes (if no one visits the page it doesn't run until someone does)</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>$current_time = time();
  
  if($current_time &gt;= $last_run + (60 * 10)) {
      echo 'foo';
      $last_run = time();
  } else {
      echo 'bar';
  }
  </code></pre>
  
  <p>What I'm expecting to get is "foo" on the screen once and when I refresh the page I want to see "bar". If I refresh the page after 10 minutes it should be "foo" again for once and then "bar" until another 10 minutes has passed.</p>
  
  <p>Currently it prints out "foo" all the time.</p>