title: PHP: if file doesn't exist then exit script
body: <pre><code>&lt;?php
  $filename = '/path/to/foo.txt';
  
  if (file_exists($filename)) {
      echo "The file $filename exists";
  }
  ?&gt;
  </code></pre>
  
  <p>That script only checks if a file exists, but how do I do something like this?</p>
  
  <pre><code>&lt;?php
  $filename = '/path/to/foo.txt';
  
  if (file doesnt exist) {
      exit("Your file doesn't exist");
  }
  ?&gt;
  </code></pre>