readfile_variation3.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --TEST--
  2. Test readfile() function: usage variation - include path
  3. --FILE--
  4. <?php
  5. /* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
  6. Description: Outputs a file
  7. */
  8. /* test readfile() by providing an include path, second argument */
  9. // include file.inc
  10. require("file.inc");
  11. $file_path = dirname(__FILE__);
  12. $dirname = "$file_path/readfile_variation3";
  13. echo "*** Testing readfile(): checking second argument, include path ***\n";
  14. // temp dir created
  15. mkdir($dirname);
  16. // temp file name used here
  17. $filename = "$dirname/readfile_variation3.tmp";
  18. // create file
  19. $fp = fopen($filename, "w");
  20. fill_file($fp, "text_with_new_line", 50);
  21. fclose($fp);
  22. // including $dirname in 'include_path'
  23. ini_set('include_path',$dirname);
  24. // 'include_path' set to true
  25. $count = readfile("readfile_variation3.tmp", true);
  26. echo "\n";
  27. var_dump($count);
  28. // use the context argument with include path
  29. echo "*** Testing readfile(): checking second argument, include path with context specified ***\n";
  30. $context = stream_context_create();
  31. $count = readfile("readfile_variation3.tmp", true, $context);
  32. echo "\n";
  33. var_dump($count);
  34. echo "Done\n";
  35. ?>
  36. --CLEAN--
  37. <?php
  38. unlink(dirname(__FILE__)."/readfile_variation3/readfile_variation3.tmp");
  39. rmdir(dirname(__FILE__)."/readfile_variation3");
  40. ?>
  41. --EXPECT--
  42. *** Testing readfile(): checking second argument, include path ***
  43. line
  44. line of text
  45. line
  46. line of text
  47. line
  48. line of t
  49. int(50)
  50. *** Testing readfile(): checking second argument, include path with context specified ***
  51. line
  52. line of text
  53. line
  54. line of text
  55. line
  56. line of t
  57. int(50)
  58. Done