1--TEST--
2Test 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
12echo "*** 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 = __DIR__ . '/fgetcsv_variation23.tmp';
17$fp = fopen ($filename, "w");
18fclose($fp);
19$fp = fopen ($filename, "r");
20if (!$fp) {
21  echo "Error: failed to create file $filename!\n";
22  exit();
23}
24var_dump( fgetcsv($fp) );
25var_dump( ftell($fp) );
26var_dump( fgetcsv($fp, 1024) );
27var_dump( ftell($fp) );
28var_dump( fgetcsv($fp, 1024, "+" ) );
29var_dump( ftell($fp) );
30var_dump( fgetcsv($fp, 1024, "+", "%") );
31var_dump( ftell($fp) );
32
33// close and delete the file
34fclose($fp);
35unlink($filename);
36echo "Done\n";
37?>
38--EXPECT--
39*** Testing fgetcsv() : reading from file which is having zero content ***
40bool(false)
41int(0)
42bool(false)
43int(0)
44bool(false)
45int(0)
46bool(false)
47int(0)
48Done
49