Annotation of embedaddon/php/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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__);
16: include($file_path."/file.inc");
17:
18: echo "*** Testing the basic functionality of file_put_contents() and file_get_contents() functions ***\n";
19:
20: echo "-- Testing with simple valid data file --\n";
21:
22: $file_name = "/file_put_contents.tmp";
23: fill_buffer($text_buffer, "text", 100);
24: file_put_contents( $file_path.$file_name, $text_buffer );
25:
26: var_dump( file_get_contents($file_path.$file_name) );
27:
28: echo "\n-- Testing with empty file --\n";
29:
30: $file_name = "/file_put_contents1.tmp";
31: file_put_contents( $file_path.$file_name, "");
32: var_dump( file_get_contents( $file_path.$file_name ) );
33:
34: echo "\n*** Done ***";
35: ?>
36: --CLEAN--
37: <?php
38: $file_path = dirname(__FILE__);
39: unlink($file_path."/file_put_contents.tmp");
40: unlink($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 --
45: string(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 --
48: string(0) ""
49:
50: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>