xref: /PHP-7.4/ext/standard/tests/file/fgetss.phpt (revision 26dfce7f)
1--TEST--
2fgetss() tests
3--FILE--
4<?php
5
6$filename = __DIR__."/fgetss.html";
7
8$array = array(
9	"askasdfasdf<b>aaaaaa\n</b>dddddd",
10	"asdqw<i onClick=\"hello();\">\naaaa<>qqqq",
11	"aaa<script>function foo() {}</script>qqq",
12	"asdasd<a\n asdjeje",
13	"",
14	"some text \n<b>blah</i>",
15	"some another text <> hoho </>"
16	);
17
18foreach ($array as $str) {
19	file_put_contents($filename, $str);
20	$fp = fopen($filename, "r");
21	var_dump(fgetss($fp));
22	var_dump(fgetss($fp));
23}
24
25foreach ($array as $str) {
26	file_put_contents($filename, $str);
27	$fp = fopen($filename, "r");
28	var_dump(fgetss($fp, 10));
29	var_dump(fgetss($fp, 10));
30}
31
32var_dump(fgetss($fp, -10));
33var_dump(fgetss($fp, 0));
34fclose($fp);
35var_dump(fgetss($fp, 0));
36
37@unlink($filename);
38
39echo "Done\n";
40?>
41--EXPECTF--
42Deprecated: Function fgetss() is deprecated in %s on line %d
43string(18) "askasdfasdfaaaaaa
44"
45
46Deprecated: Function fgetss() is deprecated in %s on line %d
47string(6) "dddddd"
48
49Deprecated: Function fgetss() is deprecated in %s on line %d
50string(6) "asdqw
51"
52
53Deprecated: Function fgetss() is deprecated in %s on line %d
54string(8) "aaaaqqqq"
55
56Deprecated: Function fgetss() is deprecated in %s on line %d
57string(23) "aaafunction foo() {}qqq"
58
59Deprecated: Function fgetss() is deprecated in %s on line %d
60bool(false)
61
62Deprecated: Function fgetss() is deprecated in %s on line %d
63string(6) "asdasd"
64
65Deprecated: Function fgetss() is deprecated in %s on line %d
66string(0) ""
67
68Deprecated: Function fgetss() is deprecated in %s on line %d
69bool(false)
70
71Deprecated: Function fgetss() is deprecated in %s on line %d
72bool(false)
73
74Deprecated: Function fgetss() is deprecated in %s on line %d
75string(11) "some text
76"
77
78Deprecated: Function fgetss() is deprecated in %s on line %d
79string(4) "blah"
80
81Deprecated: Function fgetss() is deprecated in %s on line %d
82string(24) "some another text  hoho "
83
84Deprecated: Function fgetss() is deprecated in %s on line %d
85bool(false)
86
87Deprecated: Function fgetss() is deprecated in %s on line %d
88string(9) "askasdfas"
89
90Deprecated: Function fgetss() is deprecated in %s on line %d
91string(6) "dfaaaa"
92
93Deprecated: Function fgetss() is deprecated in %s on line %d
94string(5) "asdqw"
95
96Deprecated: Function fgetss() is deprecated in %s on line %d
97string(0) ""
98
99Deprecated: Function fgetss() is deprecated in %s on line %d
100string(3) "aaa"
101
102Deprecated: Function fgetss() is deprecated in %s on line %d
103string(7) "functio"
104
105Deprecated: Function fgetss() is deprecated in %s on line %d
106string(6) "asdasd"
107
108Deprecated: Function fgetss() is deprecated in %s on line %d
109string(0) ""
110
111Deprecated: Function fgetss() is deprecated in %s on line %d
112bool(false)
113
114Deprecated: Function fgetss() is deprecated in %s on line %d
115bool(false)
116
117Deprecated: Function fgetss() is deprecated in %s on line %d
118string(9) "some text"
119
120Deprecated: Function fgetss() is deprecated in %s on line %d
121string(2) "
122"
123
124Deprecated: Function fgetss() is deprecated in %s on line %d
125string(9) "some anot"
126
127Deprecated: Function fgetss() is deprecated in %s on line %d
128string(9) "her text "
129
130Deprecated: Function fgetss() is deprecated in %s on line %d
131
132Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d
133bool(false)
134
135Deprecated: Function fgetss() is deprecated in %s on line %d
136
137Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d
138bool(false)
139
140Deprecated: Function fgetss() is deprecated in %s on line %d
141
142Warning: fgetss(): supplied resource is not a valid stream resource in %s on line %d
143bool(false)
144Done
145