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 12/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]]) 13 * Description: Write/Create a file with contents data and return the number of bytes written 14 * Source code: ext/standard/file.c 15 * Alias to functions: 16 */ 17 18echo "*** Testing file_put_contents() : usage variation ***\n"; 19 20$filename = dirname(__FILE__).'/fileGetContentsVar9.tmp'; 21$softlink = dirname(__FILE__).'/fileGetContentsVar9.SoftLink'; 22$hardlink = dirname(__FILE__).'/fileGetContentsVar9.HardLink'; 23$chainlink = dirname(__FILE__).'/fileGetContentsVar9.ChainLink'; 24 25 26// link files even though it original file doesn't exist yet 27symlink($filename, $softlink); 28symlink($softlink, $chainlink); 29 30 31// perform tests 32run_test($chainlink); 33run_test($softlink); 34 35//can only create a hardlink if the file exists. 36file_put_contents($filename,""); 37link($filename, $hardlink); 38run_test($hardlink); 39 40unlink($chainlink); 41unlink($softlink); 42unlink($hardlink); 43unlink($filename); 44 45 46function run_test($file) { 47 $data = "Here is some data"; 48 $extra = ", more data"; 49 var_dump(file_put_contents($file, $data)); 50 var_dump(file_put_contents($file, $extra, FILE_APPEND)); 51 readfile($file); 52 echo "\n"; 53} 54 55 56echo "\n*** Done ***\n"; 57?> 58--EXPECT-- 59*** Testing file_put_contents() : usage variation *** 60int(17) 61int(11) 62Here is some data, more data 63int(17) 64int(11) 65Here is some data, more data 66int(17) 67int(11) 68Here is some data, more data 69 70*** Done *** 71