1--TEST-- 2Test file() function : error conditions 3--FILE-- 4<?php 5/* 6 Prototype: array file ( string filename [,int use-include_path [,resource context]] ); 7 Description: Reads entire file into an array 8 Returns the file in an array 9*/ 10$file_path = dirname(__FILE__); 11echo "\n*** Testing error conditions ***"; 12$file_handle = fopen($file_path."/file.tmp", "w"); 13var_dump( file() ); // Zero No. of args 14 15$filename = $file_path."/file.tmp"; 16var_dump( file($filename, $filename, $filename, $filename) ); // more than expected number of arguments 17 18var_dump( file($filename, "INCORRECT_FLAG", NULL) ); // Incorrect flag 19var_dump( file($filename, 10, NULL) ); // Incorrect flag 20 21var_dump( file("temp.tmp") ); // non existing filename 22fclose($file_handle); 23 24echo "\n--- Done ---"; 25?> 26--CLEAN-- 27<?php 28$file_path = dirname(__FILE__); 29unlink($file_path."/file.tmp"); 30?> 31--EXPECTF-- 32*** Testing error conditions *** 33Warning: file() expects at least 1 parameter, 0 given in %s on line %d 34NULL 35 36Warning: file() expects at most 3 parameters, 4 given in %s on line %d 37NULL 38 39Warning: file() expects parameter 2 to be integer, string given in %s on line %d 40NULL 41array(0) { 42} 43 44Warning: file(temp.tmp): failed to open stream: No such file or directory in %s on line %d 45bool(false) 46 47--- Done --- 48 49