1--TEST--
2Test is_file() function: usage variations - diff. files
3--FILE--
4<?php
5/* Prototype: bool is_file ( string $filename );
6   Description: Tells whether the filename is a regular file
7     Returns TRUE if the filename exists and is a regular file
8*/
9
10/* Testing is_file() with file containing data, truncating its size
11     and the file created by touch() */
12
13$file_path = dirname(__FILE__);
14
15echo "-- Testing is_file() with file containing data --\n";
16$filename = $file_path."/is_file_variation1.tmp";
17$file_handle = fopen($filename, "w" );
18fwrite( $file_handle, "Hello, world....." ); // exptected true
19fclose($file_handle);
20var_dump( is_file($filename) );
21clearstatcache();
22
23echo "\n-- Testing is_file() after truncating filesize to zero bytes --\n";
24$file_handle = fopen( $file_path."/is_file_variation1.tmp", "r");
25ftruncate($file_handle, 0);
26fclose($file_handle);
27var_dump( is_file($file_path."/is_file_variation1.tmp") ); // expected true
28clearstatcache();
29unlink($file_path."/is_file_variation1.tmp");
30
31echo "\n-- Testing is_file() with an empty file --\n";
32/* created by fopen() */
33fclose( fopen($file_path."/is_file_variation1.tmp", "w") );
34var_dump( is_file($file_path."/is_file_variation1.tmp") );  //expected true
35clearstatcache();
36unlink($file_path."/is_file_variation1.tmp");
37
38/* created by touch() */
39touch($file_path."/is_file_variation1.tmp");
40var_dump( is_file($file_path."/is_file_variation1.tmp") ); // expected true
41clearstatcache();
42unlink($file_path."/is_file_variation1.tmp");
43
44echo "\n*** Done ***";
45?>
46--EXPECTF--
47-- Testing is_file() with file containing data --
48bool(true)
49
50-- Testing is_file() after truncating filesize to zero bytes --
51bool(true)
52
53-- Testing is_file() with an empty file --
54bool(true)
55bool(true)
56
57*** Done ***
58