Advertisement
Guest User

file_exits error - reproduction try

a guest
Feb 27th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. // create random file name
  4. $file = '/tmp/' . uniqid();
  5.  
  6. // the file doesn't exist yet
  7. var_dump(file_exists($file)); // false
  8.  
  9. // create the file
  10. file_put_contents($file, 'test');
  11. var_dump(file_exists($file)); // true
  12.  
  13. // as the manual points out, unlink will clear the cache
  14. // use the shell to remove the file
  15. `rm '$file'`;
  16.  
  17. // can return true when results get cached
  18. if(file_exists($file)) {
  19.     // behaviour like mentioned in PHP documentation
  20.     echo 'error'; // never happended at my machine
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement