file_basic.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --TEST--
  2. Test file() function : basic functionality
  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. require(dirname(__FILE__) . '/file.inc');
  11. $file_path = dirname(__FILE__);
  12. echo "*** Testing file() with basic types of files ***\n";
  13. $filetypes = array("numeric", "text", "empty", "text_with_new_line");
  14. foreach( $filetypes as $type ) {
  15. create_files($file_path, 1, $type, 0755, 100, "w", "file_basic", 1, "byte");
  16. print_r( file($file_path."/file_basic1.tmp") );
  17. delete_files($file_path, 1, "file_basic");
  18. }
  19. echo "*** Testing for return type of file() function ***\n";
  20. foreach( $filetypes as $type ) {
  21. create_files($file_path, 1, $type, 0755, 1, "w", "file_basic");
  22. $ret_arr = file($file_path."/file_basic1.tmp");
  23. var_dump( is_array($ret_arr) );
  24. delete_files($file_path, 1, "file_basic");
  25. }
  26. echo "\n--- Done ---";
  27. ?>
  28. --EXPECTF--
  29. *** Testing file() with basic types of files ***
  30. Array
  31. (
  32. [0] => 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
  33. )
  34. Array
  35. (
  36. [0] => text text text text text text text text text text text text text text text text text text text text
  37. )
  38. Array
  39. (
  40. )
  41. Array
  42. (
  43. [0] => line
  44. [1] => line of text
  45. [2] => line
  46. [3] => line of text
  47. [4] => line
  48. [5] => line of text
  49. [6] => line
  50. [7] => line of text
  51. [8] => line
  52. [9] => line of text
  53. [10] => line
  54. [11] => line
  55. )
  56. *** Testing for return type of file() function ***
  57. bool(true)
  58. bool(true)
  59. bool(true)
  60. bool(true)
  61. --- Done ---