fopen_variation12.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Test fopen() function : variation: use include path (path is bad) create a file (relative)
  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. set_include_path("rubbish");
  13. testme();
  14. restore_include_path();
  15. function testme() {
  16. $tmpfile = basename(__FILE__, ".php") . ".tmp";
  17. $h = fopen($tmpfile, "w", true);
  18. fwrite($h, (binary) "This is the test file");
  19. fclose($h);
  20. $h = @fopen($tmpfile, "r");
  21. if ($h === false) {
  22. echo "Not created in working dir\n";
  23. }
  24. else {
  25. echo "created in working dir\n";
  26. fclose($h);
  27. unlink($tmpfile);
  28. }
  29. $scriptDirFile = dirname(__FILE__).'/'.$tmpfile;
  30. $h = @fopen($scriptDirFile, "r");
  31. if ($h === false) {
  32. echo "Not created in script dir\n";
  33. }
  34. else {
  35. echo "created in script dir\n";
  36. fclose($h);
  37. unlink($scriptDirFile);
  38. }
  39. }
  40. ?>
  41. ===DONE===
  42. --EXPECT--
  43. created in working dir
  44. Not created in script dir
  45. ===DONE===