fopen_variation6.phpt 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. Test fopen() function : variation: use include path and stream context relative/absolute file
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --FILE--
  6. <?php
  7. /* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
  8. * Description: Open a file or a URL and return a file pointer
  9. * Source code: ext/standard/file.c
  10. * Alias to functions:
  11. */
  12. echo "*** Testing fopen() : variation ***\n";
  13. $absfile = __FILE__.'.tmp';
  14. $relfile = "fopen_variation6.tmp";
  15. $h = fopen($absfile, "w");
  16. fwrite($h, "This is an absolute file");
  17. fclose($h);
  18. $h = fopen($relfile, "w");
  19. fwrite($h, "This is a relative file");
  20. fclose($h);
  21. $ctx = stream_context_create();
  22. $h = fopen($absfile, "r", true, $ctx);
  23. fpassthru($h);
  24. fclose($h);
  25. echo "\n";
  26. $h = fopen($relfile, "r", true, $ctx);
  27. fpassthru($h);
  28. fclose($h);
  29. echo "\n";
  30. unlink($absfile);
  31. unlink($relfile);
  32. ?>
  33. ===DONE===
  34. --EXPECTF--
  35. *** Testing fopen() : variation ***
  36. This is an absolute file
  37. This is a relative file
  38. ===DONE===