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