1--TEST-- 2Test file_put_contents() and file_get_contents() functions : basic functionality 3--FILE-- 4<?php 5 6/* Prototype: string file_get_contents( string $filename[, bool $use_include_path[, 7 * resource $context[, int $offset[, int $maxlen]]]] ) 8 * Description: Reads entire file into a string 9 */ 10 11/* Prototype: int file_put_contents( string $filename, mixed $data[, int $flags[, resource $context]] ) 12 * Description: Write a string to a file 13 */ 14 15$file_path = dirname(__FILE__); 16include($file_path."/file.inc"); 17 18echo "*** Testing the basic functionality of file_put_contents() and file_get_contents() functions ***\n"; 19 20echo "-- Testing with simple valid data file --\n"; 21 22$file_name = "/file_put_contents.tmp"; 23fill_buffer($text_buffer, "text", 100); 24file_put_contents( $file_path.$file_name, $text_buffer ); 25 26var_dump( file_get_contents($file_path.$file_name) ); 27 28echo "\n-- Testing with empty file --\n"; 29 30$file_name = "/file_put_contents1.tmp"; 31file_put_contents( $file_path.$file_name, ""); 32var_dump( file_get_contents( $file_path.$file_name ) ); 33 34echo "\n*** Done ***"; 35?> 36--CLEAN-- 37<?php 38$file_path = dirname(__FILE__); 39unlink($file_path."/file_put_contents.tmp"); 40unlink($file_path."/file_put_contents1.tmp"); 41?> 42--EXPECTF-- 43*** Testing the basic functionality of file_put_contents() and file_get_contents() functions *** 44-- Testing with simple valid data file -- 45string(100) "text text text text text text text text text text text text text text text text text text text text " 46 47-- Testing with empty file -- 48string(0) "" 49 50*** Done *** 51