Annotation of embedaddon/php/ext/standard/tests/file/fgetcsv_variation23.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fgetcsv() : usage variations - empty file
3: --FILE--
4: <?php
5: /*
6: Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
7: Description: Gets line from file pointer and parse for CSV fields
8: */
9:
10: /* Testing fgetcsv() to read from an empty file */
11:
12: echo "*** Testing fgetcsv() : reading from file which is having zero content ***\n";
13:
14: // try reading from file which is having zero content
15: // create the file and then open in read mode and try reading
16: $filename = dirname(__FILE__) . '/fgetcsv_variation23.tmp';
17: $fp = fopen ($filename, "w");
18: fclose($fp);
19: $fp = fopen ($filename, "r");
20: if (!$fp) {
21: echo "Error: failed to create file $filename!\n";
22: exit();
23: }
24: var_dump( fgetcsv($fp) );
25: var_dump( ftell($fp) );
26: var_dump( fgetcsv($fp, 1024) );
27: var_dump( ftell($fp) );
28: var_dump( fgetcsv($fp, 1024, "+" ) );
29: var_dump( ftell($fp) );
30: var_dump( fgetcsv($fp, 1024, "+", "%") );
31: var_dump( ftell($fp) );
32:
33: // close and delete the file
34: fclose($fp);
35: unlink($filename);
36: echo "Done\n";
37: ?>
38: --EXPECT--
39: *** Testing fgetcsv() : reading from file which is having zero content ***
40: bool(false)
41: int(0)
42: bool(false)
43: int(0)
44: bool(false)
45: int(0)
46: bool(false)
47: int(0)
48: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>