readfile_variation1.phpt 849 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Test readfile() function: usage variation - stream_context
  3. --FILE--
  4. <?php
  5. /* test readfile() with third argument : context */
  6. // include file.inc
  7. require("file.inc");
  8. $file_path = __DIR__;
  9. /* Variation 1 : Check working of third argument of readfile() */
  10. echo "*** Testing readfile(): checking third argument ***\n";
  11. // creating a context
  12. $context = stream_context_create();
  13. // temp file name used here
  14. $filename = "$file_path/readfile_variation1.tmp";
  15. // create file
  16. $fp = fopen($filename, "w");
  17. fill_file($fp, "text_with_new_line", 50);
  18. fclose($fp);
  19. $count = readfile($filename, true, $context);
  20. echo "\n";
  21. var_dump($count);
  22. echo "Done\n";
  23. ?>
  24. --CLEAN--
  25. <?php
  26. unlink(__DIR__."/readfile_variation1.tmp");
  27. ?>
  28. --EXPECT--
  29. *** Testing readfile(): checking third argument ***
  30. line
  31. line of text
  32. line
  33. line of text
  34. line
  35. line of t
  36. int(50)
  37. Done