1--TEST-- 2Test fopen() function : variation: use include path create a file (relative) 3--CREDITS-- 4Dave 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 13require_once('fopen_include_path.inc'); 14 15$thisTestDir = basename(__FILE__, ".php") . ".dir"; 16mkdir($thisTestDir); 17chdir($thisTestDir); 18 19$newpath = create_include_path(); 20set_include_path($newpath); 21runtest(); 22$newpath = generate_next_path(); 23set_include_path($newpath); 24runtest(); 25 26teardown_include_path(); 27chdir(".."); 28rmdir($thisTestDir); 29 30function runtest() { 31 global $dir1; 32 $tmpfile = basename(__FILE__, ".php") . ".tmp"; 33 $h = fopen($tmpfile, "w", true); 34 fwrite($h, "This is the test file"); 35 fclose($h); 36 37 38 $h = @fopen($tmpfile, "r"); 39 if ($h === false) { 40 echo "Not created in working dir\n"; 41 } 42 else { 43 echo "created in working dir\n"; 44 fclose($h); 45 unlink($tmpfile); 46 } 47 48 $h = @fopen($dir1.'/'.$tmpfile, "r"); 49 if ($h === false) { 50 echo "Not created in dir1\n"; 51 } 52 else { 53 echo "created in dir1\n"; 54 fclose($h); 55 unlink($dir1.'/'.$tmpfile); 56 } 57} 58?> 59===DONE=== 60--EXPECT-- 61created in working dir 62Not created in dir1 63created in working dir 64Not created in dir1 65===DONE=== 66