import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-file / file_put_contents_variation6.php
blob12fc040e74926b3d8f04e64c0a426fda2f5b34c8
1 <?php
2 /* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
3 * Description: Write/Create a file with contents data and return the number of bytes written
4 * Source code: ext/standard/file.c
5 * Alias to functions:
6 */
8 echo "*** Testing file_put_contents() : variation ***\n";
10 require_once('fopen_include_path.inc');
12 $thisTestDir = basename(__FILE__, ".php") . ".dir";
13 mkdir($thisTestDir);
14 chdir($thisTestDir);
16 $filename = basename(__FILE__, ".php") . ".tmp";
18 $newpath = create_include_path();
19 set_include_path($newpath);
20 runtest();
22 $newpath = generate_next_path();
23 set_include_path($newpath);
24 runtest();
26 teardown_include_path();
27 restore_include_path();
28 chdir("..");
29 rmdir($thisTestDir);
32 function runtest() {
33 global $filename;
35 //correct php53 behaviour is to ignore the FILE_USE_INCLUDE_PATH unless the file already exists
36 // in the include path. In this case it doesn't so the file should be written in the current dir.
38 file_put_contents($filename, (binary) "File in include path", FILE_USE_INCLUDE_PATH);
39 file_put_contents($filename, (binary) ". This was appended", FILE_USE_INCLUDE_PATH | FILE_APPEND);
40 $line = file_get_contents($filename);
41 echo "$line\n";
42 unlink($filename);
46 ===DONE===