View difference between Paste ID: VSMVWqS0 and pPbV1DiV
SHOW: | | - or go back to the newest paste.
1
<?php
2
3-
$file = '/tmp/' . uniqid();
3+
// create random file name
4-
var_dump(file_exists($file));
4+
$file = '/tmp/' . uniqid(); 
5
6
// the file doesn't exist yet
7-
var_dump(file_exists($file));
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
}