1--TEST-- 2fgetss() tests 3--FILE-- 4<?php 5 6$filename = dirname(__FILE__)."/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-- 42string(18) "askasdfasdfaaaaaa 43" 44string(6) "dddddd" 45string(6) "asdqw 46" 47string(8) "aaaaqqqq" 48string(23) "aaafunction foo() {}qqq" 49bool(false) 50string(6) "asdasd" 51string(0) "" 52bool(false) 53bool(false) 54string(11) "some text 55" 56string(4) "blah" 57string(24) "some another text hoho " 58bool(false) 59string(9) "askasdfas" 60string(6) "dfaaaa" 61string(5) "asdqw" 62string(0) "" 63string(3) "aaa" 64string(7) "functio" 65string(6) "asdasd" 66string(0) "" 67bool(false) 68bool(false) 69string(9) "some text" 70string(2) " 71" 72string(9) "some anot" 73string(9) "her text " 74 75Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d 76bool(false) 77 78Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d 79bool(false) 80 81Warning: fgetss(): %d is not a valid stream resource in %s on line %d 82bool(false) 83Done 84