1--TEST-- 2Test fopen() function : variation: use include path and stream context create a file, relative path 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--FILE-- 6<?php 7require_once('fopen_include_path.inc'); 8 9$thisTestDir = basename(__FILE__, ".php") . ".dir"; 10mkdir($thisTestDir); 11chdir($thisTestDir); 12 13$newpath = relative_include_path(); 14set_include_path($newpath); 15runtest(); 16 17$newpath = generate_next_rel_path(); 18set_include_path($newpath); 19runtest(); 20 21teardown_relative_path(); 22chdir(".."); 23rmdir($thisTestDir); 24 25function runtest() { 26 $tmpfile = basename(__FILE__, ".php") . ".tmp"; 27 $h = fopen($tmpfile, "w", true); 28 fwrite($h, "This is the test file"); 29 fclose($h); 30 31 32 $h = @fopen($tmpfile, "r"); 33 if ($h === false) { 34 echo "Not created in working dir\n"; 35 } 36 else { 37 echo "created in working dir\n"; 38 fclose($h); 39 unlink($tmpfile); 40 } 41 42 $h = @fopen('dir1/'.$tmpfile, "r"); 43 if ($h === false) { 44 echo "Not created in dir1\n"; 45 } 46 else { 47 echo "created in dir1\n"; 48 fclose($h); 49 unlink('dir1/'.$tmpfile); 50 } 51} 52?> 53--EXPECT-- 54created in working dir 55Not created in dir1 56created in working dir 57Not created in dir1 58