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