xref: /PHP-7.0/ext/standard/tests/file/fgetss1.phpt (revision ab072655)
1--TEST--
2more fgetss() tests
3--FILE--
4<?php
5
6$filename = dirname(__FILE__)."/fgetss1.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, 1000, "<i>,<b>,<a>"));
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, "<script>,<a>"));
30}
31
32echo "Done\n";
33?>
34--CLEAN--
35<?php
36$filename = dirname(__FILE__)."/fgetss1.html";
37unlink($filename);
38?>
39--EXPECTF--
40string(21) "askasdfasdf<b>aaaaaa
41"
42string(6) "dddddd"
43string(28) "asdqw<i onClick="hello();">
44"
45string(8) "aaaaqqqq"
46string(23) "aaafunction foo() {}qqq"
47bool(false)
48string(6) "asdasd"
49string(0) ""
50bool(false)
51bool(false)
52string(11) "some text
53"
54string(4) "blah"
55string(24) "some another text  hoho "
56bool(false)
57string(9) "askasdfas"
58string(6) "dfaaaa"
59string(5) "asdqw"
60string(0) ""
61string(3) "aaa"
62string(9) "t>functio"
63string(6) "asdasd"
64string(0) ""
65bool(false)
66bool(false)
67string(9) "some text"
68string(2) "
69"
70string(9) "some anot"
71string(9) "her text "
72Done
73