2 /* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
3 * Description: Open a file or a URL and return a file pointer
4 * Source code: ext/standard/file.c
8 echo "*** Testing fopen() : variation ***\n";
10 // fopen with interesting windows paths.
11 $includePathDir = getcwd().'/fopen15.includeDir';
12 $testDir = 'fopen15.tmpDir';
13 $absTestDir = getcwd().'/'.$testDir;
14 $file = "fopen_variation15.tmp";
15 $absFile = $absTestDir.'/'.$file;
18 mkdir($includePathDir);
19 set_include_path($includePathDir);
21 $files = array("file://$testDir/$file",
22 "file://./$testDir/$file",
23 "file://$absTestDir/$file"
29 $files = array("file://../$testDir/$file",
30 "file://$absTestDir/$file"
35 rmdir($includePathDir);
37 function runtest($fileURIs) {
40 foreach($fileURIs as $fileURI) {
41 echo "--- READ: $fileURI ---\n";
43 $readData = "read:$iteration";
44 $writeData = "write:$iteration";
46 // create the file and test read
47 $h = fopen($absFile, 'w');
48 fwrite($h, $readData);
51 $h = fopen($fileURI, 'r', true);
53 if (fread($h, 4096) != $readData) {
54 echo "contents not correct\n";
63 echo "--- WRITE: $fileURI ---\n";
64 // create the file to test write
65 $h = fopen($fileURI, 'w', true);
67 fwrite($h, $writeData);
70 $h = fopen($absFile, 'r');
72 if (fread($h, 4096) != $writeData) {
73 echo "contents not correct\n";