1--TEST-- 2Test fopen() function : variation: use include path create and read 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 = "fopenVariation16.dir"; 16mkdir($thisTestDir); 17chdir($thisTestDir); 18 19$newpath = create_include_path(); 20set_include_path($newpath); 21runtest(); 22 23$newpath = generate_next_path(); 24set_include_path($newpath); 25runtest(); 26 27teardown_include_path(); 28restore_include_path(); 29chdir(".."); 30rmdir($thisTestDir); 31 32function runtest() { 33 global $dir1; 34 35 $extraDir = "extraDir16"; 36 37 mkdir($dir1.'/'.$extraDir); 38 mkdir($extraDir); 39 40 $tmpfile = $extraDir.'/fopen_variation16.tmp'; 41 42 $h = fopen($tmpfile, "w+", true); 43 fwrite($h, (binary) "This is the test file"); 44 fclose($h); 45 46 $h = @fopen($dir1.'/'.$tmpfile, "r"); 47 if ($h === false) { 48 echo "Not created in dir1\n"; 49 } 50 else { 51 echo "created in dir1\n"; 52 fclose($h); 53 } 54 55 $h = fopen($tmpfile, "r", true); 56 if ($h === false) { 57 echo "could not find file for reading\n"; 58 } 59 else { 60 echo "found file - not in dir1\n"; 61 fclose($h); 62 } 63 64 unlink($tmpfile); 65 rmdir($dir1.'/'.$extraDir); 66 rmdir($extraDir); 67} 68?> 69===DONE=== 70--EXPECT-- 71Not created in dir1 72found file - not in dir1 73Not created in dir1 74found file - not in dir1 75===DONE=== 76