1--TEST--
2Test fpassthru() function: Basic functionality
3--FILE--
4<?php
5$file_name = __DIR__."/passthru.tmp";
6$write_handle = fopen($file_name, "w");
7
8$string = "Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^
9          Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^\n";
10if(substr(PHP_OS, 0, 3) == "WIN")  {
11    $string = str_replace("\r",'', $string);
12}
13fwrite($write_handle, $string);
14fclose($write_handle);
15
16$read_handle = fopen($file_name, "r");
17
18echo "*** Test basic functionality of fpassthru() function ***\n";
19echo "\n-- Before seek operation --\n";
20var_dump( fpassthru($read_handle) );
21
22echo "\n-- After seeking position to 0 --\n";
23fseek($read_handle, 0);
24var_dump( fpassthru($read_handle) );
25
26echo "\n-- After seeking position to 3 --\n";
27fseek($read_handle, 3);
28var_dump( fpassthru($read_handle) );
29
30echo "\n-- After seeking position to 13 --\n";
31fseek($read_handle, 13);
32var_dump( fpassthru($read_handle) );
33
34echo "\n-- After seeking position to 14 --\n";
35fseek($read_handle, 14);
36var_dump( fpassthru($read_handle) );
37
38echo "\n-- After seeking position to 23 --\n";
39fseek($read_handle, 23);
40var_dump( fpassthru($read_handle) );
41
42echo "\n-- After seeking position to 34 --\n";
43fseek($read_handle, 34);
44var_dump( fpassthru($read_handle) );
45
46echo "\n-- After seeking position to 1000 --\n";
47fseek($read_handle, 1000);
48var_dump( fpassthru($read_handle) );
49
50fclose($read_handle);
51
52echo "*** Done ***\n";
53
54?>
55--CLEAN--
56<?php
57unlink(__DIR__."/passthru.tmp");
58?>
59--EXPECT--
60*** Test basic functionality of fpassthru() function ***
61
62-- Before seek operation --
63Hello, world
64, abcdefg	adsdsfdf
658u2394723947	$%$%#$%#$%#^#%^
66          Hello, world
67, abcdefg	adsdsfdf
688u2394723947	$%$%#$%#$%#^#%^
69int(132)
70
71-- After seeking position to 0 --
72Hello, world
73, abcdefg	adsdsfdf
748u2394723947	$%$%#$%#$%#^#%^
75          Hello, world
76, abcdefg	adsdsfdf
778u2394723947	$%$%#$%#$%#^#%^
78int(132)
79
80-- After seeking position to 3 --
81lo, world
82, abcdefg	adsdsfdf
838u2394723947	$%$%#$%#$%#^#%^
84          Hello, world
85, abcdefg	adsdsfdf
868u2394723947	$%$%#$%#$%#^#%^
87int(129)
88
89-- After seeking position to 13 --
90, abcdefg	adsdsfdf
918u2394723947	$%$%#$%#$%#^#%^
92          Hello, world
93, abcdefg	adsdsfdf
948u2394723947	$%$%#$%#$%#^#%^
95int(119)
96
97-- After seeking position to 14 --
98 abcdefg	adsdsfdf
998u2394723947	$%$%#$%#$%#^#%^
100          Hello, world
101, abcdefg	adsdsfdf
1028u2394723947	$%$%#$%#$%#^#%^
103int(118)
104
105-- After seeking position to 23 --
106adsdsfdf
1078u2394723947	$%$%#$%#$%#^#%^
108          Hello, world
109, abcdefg	adsdsfdf
1108u2394723947	$%$%#$%#$%#^#%^
111int(109)
112
113-- After seeking position to 34 --
1142394723947	$%$%#$%#$%#^#%^
115          Hello, world
116, abcdefg	adsdsfdf
1178u2394723947	$%$%#$%#$%#^#%^
118int(98)
119
120-- After seeking position to 1000 --
121int(0)
122*** Done ***
123