1--TEST--
2Test fpassthru() function: Basic functionality
3--FILE--
4<?php
5/*
6Prototype: int fpassthru ( resource $handle );
7Description: Reads to EOF on the given file pointer from the current position
8  and writes the results to the output buffer.
9*/
10
11$file_name = dirname(__FILE__)."/passthru.tmp";
12$write_handle = fopen($file_name, "w");
13
14$string = "Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^
15          Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^\n";
16if(substr(PHP_OS, 0, 3) == "WIN")  {
17	$string = str_replace("\r",'', $string);
18}
19fwrite($write_handle, $string);
20fclose($write_handle);
21
22$read_handle = fopen($file_name, "r");
23
24echo "*** Test basic functionality of fpassthru() function ***\n";
25echo "\n-- Before seek operation --\n";
26var_dump( fpassthru($read_handle) );
27
28echo "\n-- After seeking position to 0 --\n";
29fseek($read_handle, 0);
30var_dump( fpassthru($read_handle) );
31
32echo "\n-- After seeking position to 3 --\n";
33fseek($read_handle, 3);
34var_dump( fpassthru($read_handle) );
35
36echo "\n-- After seeking position to 13 --\n";
37fseek($read_handle, 13);
38var_dump( fpassthru($read_handle) );
39
40echo "\n-- After seeking position to 14 --\n";
41fseek($read_handle, 14);
42var_dump( fpassthru($read_handle) );
43
44echo "\n-- After seeking position to 23 --\n";
45fseek($read_handle, 23);
46var_dump( fpassthru($read_handle) );
47
48echo "\n-- After seeking position to 34 --\n";
49fseek($read_handle, 34);
50var_dump( fpassthru($read_handle) );
51
52echo "\n-- After seeking position to 1000 --\n";
53fseek($read_handle, 1000);
54var_dump( fpassthru($read_handle) );
55
56fclose($read_handle);
57
58echo "*** Done ***\n";
59
60?>
61--CLEAN--
62<?php
63unlink(dirname(__FILE__)."/passthru.tmp");
64?>
65--EXPECTF--
66*** Test basic functionality of fpassthru() function ***
67
68-- Before seek operation --
69Hello, world
70, abcdefg	adsdsfdf
718u2394723947	$%$%#$%#$%#^#%^
72          Hello, world
73, abcdefg	adsdsfdf
748u2394723947	$%$%#$%#$%#^#%^
75int(133)
76
77-- After seeking position to 0 --
78Hello, world
79, abcdefg	adsdsfdf
808u2394723947	$%$%#$%#$%#^#%^
81          Hello, world
82, abcdefg	adsdsfdf
838u2394723947	$%$%#$%#$%#^#%^
84int(133)
85
86-- After seeking position to 3 --
87lo, world
88, abcdefg	adsdsfdf
898u2394723947	$%$%#$%#$%#^#%^
90          Hello, world
91, abcdefg	adsdsfdf
928u2394723947	$%$%#$%#$%#^#%^
93int(130)
94
95-- After seeking position to 13 --
96, abcdefg	adsdsfdf
978u2394723947	$%$%#$%#$%#^#%^
98          Hello, world
99, abcdefg	adsdsfdf
1008u2394723947	$%$%#$%#$%#^#%^
101int(120)
102
103-- After seeking position to 14 --
104 abcdefg	adsdsfdf
1058u2394723947	$%$%#$%#$%#^#%^
106          Hello, world
107, abcdefg	adsdsfdf
1088u2394723947	$%$%#$%#$%#^#%^
109int(119)
110
111-- After seeking position to 23 --
112adsdsfdf
1138u2394723947	$%$%#$%#$%#^#%^
114          Hello, world
115, abcdefg	adsdsfdf
1168u2394723947	$%$%#$%#$%#^#%^
117int(110)
118
119-- After seeking position to 34 --
1202394723947	$%$%#$%#$%#^#%^
121          Hello, world
122, abcdefg	adsdsfdf
1238u2394723947	$%$%#$%#$%#^#%^
124int(99)
125
126-- After seeking position to 1000 --
127int(0)
128*** Done ***
129