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 7require_once('fopen_include_path.inc'); 8 9$thisTestDir = basename(__FILE__, ".php") . ".dir"; 10mkdir($thisTestDir); 11chdir($thisTestDir); 12 13$newpath = create_include_path(); 14set_include_path($newpath); 15runtest(); 16 17$newpath = generate_next_path(); 18set_include_path($newpath); 19runtest(); 20 21teardown_include_path(); 22chdir(".."); 23rmdir($thisTestDir); 24 25function runtest() { 26 global $dir1; 27 28 $extraDir = "extraDir17"; 29 30 mkdir($dir1.'/'.$extraDir); 31 mkdir($extraDir); 32 33 $tmpfile = $extraDir . '/' . basename(__FILE__, ".php") . ".tmp"; 34 $h = fopen($tmpfile, "w+", true); 35 fwrite($h, "This is the test file"); 36 fclose($h); 37 38 $h = @fopen($dir1.'/'.$tmpfile, "r"); 39 if ($h === false) { 40 echo "Not created in dir1\n"; 41 } 42 else { 43 echo "created in dir1\n"; 44 fclose($h); 45 } 46 47 $h = fopen($tmpfile, "r", true); 48 if ($h === false) { 49 echo "could not find file for reading\n"; 50 } 51 else { 52 echo "found file for reading\n"; 53 fclose($h); 54 } 55 56 unlink($tmpfile); 57 rmdir($dir1.'/'.$extraDir); 58 rmdir($extraDir); 59} 60?> 61--EXPECT-- 62Not created in dir1 63found file for reading 64Not created in dir1 65found file for reading 66