import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-file / fopen_variation16.php
blob2298bf0958ec3cee9b926cf0e274874460c5fa75
1 <?php
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
5 * Alias to functions:
6 */
8 require_once('fopen_include_path.inc');
10 $thisTestDir = "fopenVariation16.dir";
11 mkdir($thisTestDir);
12 chdir($thisTestDir);
14 $newpath = create_include_path();
15 set_include_path($newpath);
16 runtest();
18 $newpath = generate_next_path();
19 set_include_path($newpath);
20 runtest();
22 teardown_include_path();
23 restore_include_path();
24 chdir("..");
25 rmdir($thisTestDir);
27 function runtest() {
28 global $dir1;
30 $extraDir = "extraDir";
32 mkdir($dir1.'/'.$extraDir);
33 mkdir($extraDir);
35 $tmpfile = $extraDir.'/fopen_variation16.tmp';
37 $h = fopen($tmpfile, "w+", true);
38 fwrite($h, (binary) "This is the test file");
39 fclose($h);
41 $h = @fopen($dir1.'/'.$tmpfile, "r");
42 if ($h === false) {
43 echo "Not created in dir1\n";
45 else {
46 echo "created in dir1\n";
47 fclose($h);
50 $h = fopen($tmpfile, "r", true);
51 if ($h === false) {
52 echo "could not find file for reading\n";
54 else {
55 echo "found file - not in dir1\n";
56 fclose($h);
59 unlink($tmpfile);
60 rmdir($dir1.'/'.$extraDir);
61 rmdir($extraDir);
64 ===DONE===