1--TEST--
2Test file_get_contents() and file_put_contents() functions : usage variations - all arguments
3
4--FILE--
5<?php
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/* Testing variation in all argument values */
16$file_path = dirname(__FILE__);
17include($file_path."/file.inc");
18
19echo "*** Testing with variations in the arguments values ***\n";
20
21$buffer_types = array("text", "numeric", "text_with_new_line", "alphanumeric");
22
23foreach( $buffer_types as $type) {
24  fill_buffer($buffer, $type, 100);
25  file_put_contents( $file_path."/file_put_contents_variation1.tmp", $buffer);
26  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 0) );
27  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 1) );
28  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 0, NULL, 5) );
29  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 1, NULL, 5) );
30  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 0, NULL, 5, 20) );
31  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 1, NULL, 5, 20) );
32
33}
34
35echo "--- Done ---";
36?>
37--CLEAN--
38<?php
39//Deleting the temporary file
40
41$file_path = dirname(__FILE__);
42unlink($file_path."/file_put_contents_variation1.tmp");
43?>
44--EXPECTF--
45*** Testing with variations in the arguments values ***
46string(100) "text text text text text text text text text text text text text text text text text text text text "
47string(100) "text text text text text text text text text text text text text text text text text text text text "
48string(95) "text text text text text text text text text text text text text text text text text text text "
49string(95) "text text text text text text text text text text text text text text text text text text text "
50string(20) "text text text text "
51string(20) "text text text text "
52string(100) "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
53string(100) "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
54string(95) "22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
55string(95) "22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
56string(20) "22222222222222222222"
57string(20) "22222222222222222222"
58string(100) "line
59line of text
60line
61line of text
62line
63line of text
64line
65line of text
66line
67line of text
68line
69line "
70string(100) "line
71line of text
72line
73line of text
74line
75line of text
76line
77line of text
78line
79line of text
80line
81line "
82string(95) "line of text
83line
84line of text
85line
86line of text
87line
88line of text
89line
90line of text
91line
92line "
93string(95) "line of text
94line
95line of text
96line
97line of text
98line
99line of text
100line
101line of text
102line
103line "
104string(20) "line of text
105line
106li"
107string(20) "line of text
108line
109li"
110string(100) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
111string(100) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
112string(95) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
113string(95) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
114string(20) "ab12 ab12 ab12 ab12 "
115string(20) "ab12 ab12 ab12 ab12 "
116--- Done ---
117