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 34unlink($chainlink); 35unlink($softlink); 36unlink($hardlink); 37unlink($filename); 38 39 40function run_test($file) { 41 $data = "Here is some data"; 42 $extra = ", more data"; 43 var_dump(file_put_contents($file, $data)); 44 var_dump(file_put_contents($file, $extra, FILE_APPEND)); 45 readfile($file); 46 echo "\n"; 47} 48 49 50echo "\n*** Done ***\n"; 51?> 52--EXPECT-- 53*** Testing file_put_contents() : usage variation *** 54int(17) 55int(11) 56Here is some data, more data 57int(17) 58int(11) 59Here is some data, more data 60int(17) 61int(11) 62Here is some data, more data 63 64*** Done *** 65