import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-file / 007_error.php
blob4f5fbee92d793d1c1ae5d86d8cb52f251fdf223a
1 <?php
2 /*
3 Prototype: resource fopen(string $filename, string $mode
4 [, bool $use_include_path [, resource $context]] );
5 Description: Opens file or URL.
7 Prototype: bool fclose ( resource $handle );
8 Description: Closes an open file pointer
10 Prototype: bool feof ( resource $handle )
11 Description: Returns TRUE if the file pointer is at EOF or an error occurs
12 (including socket timeout); otherwise returns FALSE.
15 echo "*** Testing error conditions for fopen(), fclsoe() & feof() ***\n";
16 /* Arguments less than minimum no.of args */
18 // fopen ()
19 var_dump(fopen(__FILE__)); // one valid argument
20 var_dump(fopen()); // zero argument
22 // fclose()
23 $fp = fopen(__FILE__, "r");
24 fclose($fp);
25 var_dump( fclose($fp) ); // closed handle
26 var_dump( fclose(__FILE__) ); // invalid handle
27 var_dump( fclose() ); // zero argument
29 //feof()
30 var_dump( feof($fp) ); // closed handle
31 var_dump( feof(__FILE__) ); // invalid handle
32 var_dump( feof() ); //zero argument
34 /* Arguments greater than maximum no.of ags */
35 var_dump(fopen(__FILE__, "r", TRUE, "www.example.com", 100));
37 $fp = fopen(__FILE__, "r");
38 var_dump( fclose($fp, "handle") );
40 var_dump( feof($fp, "handle"));
41 fclose($fp);
43 /* test invalid arguments : non-resources */
44 echo "-- Testing fopen(), fclose() & feof() with invalid arguments --\n";
45 $invalid_args = array (
46 "string",
47 10,
48 10.5,
49 true,
50 array(1,2,3),
51 new stdclass,
52 NULL,
56 /* loop to test fclose with different invalid type of args */
57 for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
58 echo "-- Iteration $loop_counter --\n";
59 var_dump( fopen($invalid_args[$loop_counter - 1], "r") );
60 var_dump( fclose($invalid_args[$loop_counter - 1]) );
61 var_dump( feof($invalid_args[$loop_counter - 1]) );