fopen_variation12.phpt 904 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. set_include_path("rubbish");
  8. testme();
  9. function testme() {
  10. $tmpfile = basename(__FILE__, ".php") . ".tmp";
  11. $h = fopen($tmpfile, "w", true);
  12. fwrite($h, "This is the test file");
  13. fclose($h);
  14. $h = @fopen($tmpfile, "r");
  15. if ($h === false) {
  16. echo "Not created in working dir\n";
  17. }
  18. else {
  19. echo "created in working dir\n";
  20. fclose($h);
  21. unlink($tmpfile);
  22. }
  23. $scriptDirFile = __DIR__.'/'.$tmpfile;
  24. $h = @fopen($scriptDirFile, "r");
  25. if ($h === false) {
  26. echo "Not created in script dir\n";
  27. }
  28. else {
  29. echo "created in script dir\n";
  30. fclose($h);
  31. unlink($scriptDirFile);
  32. }
  33. }
  34. ?>
  35. --EXPECT--
  36. created in working dir
  37. Not created in script dir