readfile_variation1.phpt 1002 B

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