1--TEST--
2est file_put_contents() function : usage variation - linked files
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) == "WIN")
8  die("skip Do not run on Windows");
9?>
10--FILE--
11<?php
12echo "*** Testing file_put_contents() : usage variation ***\n";
13
14$filename = __DIR__.'/filePutContentsVar9.tmp';
15$softlink = __DIR__.'/filePutContentsVar9.SoftLink';
16$hardlink = __DIR__.'/filePutContentsVar9.HardLink';
17$chainlink = __DIR__.'/filePutContentsVar9.ChainLink';
18
19
20// link files even though it original file doesn't exist yet
21symlink($filename, $softlink);
22symlink($softlink, $chainlink);
23
24
25// perform tests
26run_test($chainlink);
27run_test($softlink);
28
29//can only create a hardlink if the file exists.
30file_put_contents($filename,"");
31link($filename, $hardlink);
32run_test($hardlink);
33
34function run_test($file) {
35    $data = "Here is some data";
36    $extra = ", more data";
37    var_dump(file_put_contents($file, $data));
38    var_dump(file_put_contents($file, $extra, FILE_APPEND));
39    readfile($file);
40    echo "\n";
41}
42
43
44echo "\n*** Done ***\n";
45?>
46--CLEAN--
47<?php
48$filename = __DIR__.'/filePutContentsVar9.tmp';
49$softlink = __DIR__.'/filePutContentsVar9.SoftLink';
50$hardlink = __DIR__.'/filePutContentsVar9.HardLink';
51$chainlink = __DIR__.'/filePutContentsVar9.ChainLink';
52unlink($chainlink);
53unlink($softlink);
54unlink($hardlink);
55unlink($filename);
56?>
57--EXPECT--
58*** Testing file_put_contents() : usage variation ***
59int(17)
60int(11)
61Here is some data, more data
62int(17)
63int(11)
64Here is some data, more data
65int(17)
66int(11)
67Here is some data, more data
68
69*** Done ***
70